Commit 99a9491d 99a9491db8497025b91887549af1cf9b24f32b91 by xianghan

1.添加app账号维护接口

1 parent 225e5813
...@@ -23,6 +23,12 @@ import java.io.Serializable; ...@@ -23,6 +23,12 @@ import java.io.Serializable;
23 @Table(name="uc_user_app_bind") 23 @Table(name="uc_user_app_bind")
24 public class UserAppBind implements Serializable { 24 public class UserAppBind implements Serializable {
25 25
26 @Transient
27 private String username;
28
29 @Transient
30 private String password;
31
26 // 主键 32 // 主键
27 @Id 33 @Id
28 @GeneratedValue(strategy = GenerationType.IDENTITY) 34 @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -19,18 +19,38 @@ public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, ...@@ -19,18 +19,38 @@ public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>,
19 Optional<UserAppBind> findFirstByAccount(String account); 19 Optional<UserAppBind> findFirstByAccount(String account);
20 20
21 @Modifying 21 @Modifying
22 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 0 , `update_time` = now() WHERE `account` = ?1 ", nativeQuery = true) 22 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 0 , `update_time` = now() WHERE `account` = ?1 AND `account_type` = ?2", nativeQuery = true)
23 Integer cancelUserAppBind(String account); 23 Integer cancelUserAppBind(String account, Integer accountType);
24 24
25 Optional<UserAppBind> findFirstByAccountAndAccountType(String account, Integer accountType); 25 Optional<UserAppBind> findFirstByAccountAndAccountType(String account, Integer accountType);
26 26
27 @Modifying 27 @Modifying
28 @Transactional(rollbackFor = Exception.class) 28 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " +
29 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 1, `update_time` = now() WHERE `account` = ?1, accountType = ?2", nativeQuery = true) 29 " `user_app_id` = :#{#resources.userAppId}, `nickname` = :#{#resources.nickname} " +
30 Integer updateUserAppBindStatus2Valid(String account, Integer accountType); 30 " WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}", nativeQuery = true)
31 Integer updateThirdAccount(@Param("resources") UserAppBind resources);
31 32
32 @Modifying 33 @Modifying
33 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " + 34 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " +
34 " `user_app_id` = :#{#resources.userAppId}, `nickname` = :#{#resources.nickname} WHERE `account` = ?1, accountType = ?2", nativeQuery = true) 35 " `user_app_id` = :#{#resources.userAppId} WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}",
35 Integer updateUserAppBind(@Param("resources") UserAppBind userAppBind); 36 nativeQuery = true)
37 Integer updateThirdAccountStatusAndUserAppId(@Param("resources") UserAppBind resources);
38
39 @Modifying
40 @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 1, `update_time` = now(), " +
41 " `user_app_id` = :#{#resources.userAppId} WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}",
42 nativeQuery = true)
43 Integer updateValidStatusAndUserAppId(@Param("resources") UserAppBind resources);
44
45
46 @Modifying
47 @Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `nickname` = :#{#resources.nickname} " +
48 " WHERE `account` = :#{#resources.account} AND `account_type` = :#{#resources.accountType}", nativeQuery = true)
49 Integer updateThirdAccountNickname(@Param("resources") UserAppBind resources);
50
51 @Modifying
52 @Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, `status` = 1, `user_app_id` = :#{#resources.userAppId} " +
53 " WHERE `account` = :#{#resources.account} AND `account_type` = :#{#resources.accountType}", nativeQuery = true)
54 Integer updateValidStatusAndUserAppIdAndNickname(@Param("resources") UserAppBind resources);
36 } 55 }
56
......
...@@ -3,6 +3,8 @@ package com.topdraw.business.module.user.app.repository; ...@@ -3,6 +3,8 @@ package com.topdraw.business.module.user.app.repository;
3 import com.topdraw.business.module.user.app.domain.UserApp; 3 import com.topdraw.business.module.user.app.domain.UserApp;
4 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Modifying;
7 import org.springframework.data.jpa.repository.Query;
6 8
7 import java.util.Optional; 9 import java.util.Optional;
8 10
...@@ -16,4 +18,7 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec ...@@ -16,4 +18,7 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
16 18
17 Optional<UserApp> findByUsernameAndPassword(String username, String password); 19 Optional<UserApp> findByUsernameAndPassword(String username, String password);
18 20
21 @Modifying
22 @Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `last_active_time` = now() WHERE `username` = ?1", nativeQuery = true)
23 Integer updateLastActiveTime(String username);
19 } 24 }
......
1 package com.topdraw.business.module.user.app.rest; 1 package com.topdraw.business.module.user.app.rest;
2 2
3 import com.topdraw.annotation.AnonymousAccess; 3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.user.app.domain.UserApp;
5 import com.topdraw.business.module.user.app.domain.UserAppBind;
6 import com.topdraw.business.module.user.app.service.UserAppBindService;
7 import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
8 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
4 import com.topdraw.common.ResultInfo; 9 import com.topdraw.common.ResultInfo;
5 import com.topdraw.annotation.Log; 10 import com.topdraw.annotation.Log;
6 import com.topdraw.business.module.user.app.domain.UserApp;
7 import com.topdraw.business.module.user.app.service.UserAppService; 11 import com.topdraw.business.module.user.app.service.UserAppService;
8 import lombok.extern.slf4j.Slf4j; 12 import lombok.extern.slf4j.Slf4j;
13 import org.apache.commons.lang3.StringUtils;
9 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.*; 16 import org.springframework.web.bind.annotation.*;
12 import io.swagger.annotations.*; 17 import io.swagger.annotations.*;
13 18
19 import java.util.Objects;
20
14 /** 21 /**
15 * @author XiangHan 22 * @author XiangHan
16 * @date 2022-06-27 23 * @date 2022-06-27
...@@ -23,35 +30,99 @@ public class UserAppController { ...@@ -23,35 +30,99 @@ public class UserAppController {
23 30
24 @Autowired 31 @Autowired
25 private UserAppService userAppService; 32 private UserAppService userAppService;
33 @Autowired
34 private UserAppBindService userAppBindService;
26 35
27 @Log 36 @Log
28 @PostMapping 37 @PostMapping(value = "/updateLastActiveTime")
29 @ApiOperation("新增UserApp") 38 @ApiOperation("修改app账号最新登录时间")
30 @AnonymousAccess 39 @AnonymousAccess
31 public ResultInfo create(@Validated @RequestBody UserApp resources) { 40 public ResultInfo updateLastActiveTime(@Validated @RequestBody UserAppBind resources) {
32 log.info("新增App账号 ==>> param ==>> [addLogin#{}]", resources); 41 log.info("保存第三方账号 ==>> param ==>> [updateLastActiveTime#{}]", resources);
33 42 String username = resources.getUsername();
34 this.userAppService.create(resources); 43 if (StringUtils.isBlank(username)) {
35 return ResultInfo.success(); 44 log.error("修改app账号最新登录时间失败,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources);
45 return ResultInfo.failure("修改app账号最新登录时间失败,参数错误,app账号不得为空");
46 }
47 boolean result = this.userAppService.updateLastActiveTime(resources);
48 return ResultInfo.success(result);
36 } 49 }
37 50
38 @Log 51 @Log
39 @PutMapping 52 @PostMapping(value = "/saveThirdAccount")
40 @ApiOperation("修改UserApp") 53 @ApiOperation("保存第三方账号")
41 @AnonymousAccess 54 @AnonymousAccess
42 public ResultInfo update(@Validated @RequestBody UserApp resources) { 55 public ResultInfo saveThirdAccount(@Validated @RequestBody UserAppBind resources) {
43 this.userAppService.update(resources); 56 log.info("保存第三方账号, 参数 ==>> [saveUserBindApp#{}]", resources);
44 return ResultInfo.success(); 57 String username = resources.getUsername();
45 } 58 if (StringUtils.isBlank(username)) {
59 log.error("修改app账号最新登录时间失败,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources);
60 return ResultInfo.failure("修改app账号最新登录时间失败,参数错误,app账号不得为空");
61 }
62
63 UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
64 if (Objects.nonNull(userAppDTO.getId())) {
65 Long id = userAppDTO.getId();
66 resources.setUserAppId(id);
67 }
46 68
69 UserAppBindDTO userAppBindDTO = this.userAppBindService.create(resources);
70 return ResultInfo.success(userAppBindDTO);
71 }
47 72
48 @Log 73 @Log
49 @DeleteMapping(value = "/{id}") 74 @PostMapping(value = "/updateValidStatusAndUserAppIdAndNickname")
50 @ApiOperation("删除UserApp") 75 @ApiOperation("修改第三方账号")
51 @AnonymousAccess 76 @AnonymousAccess
52 public ResultInfo delete(@PathVariable Long id) { 77 public ResultInfo updateValidStatusAndUserAppIdAndNickname(@Validated @RequestBody UserAppBind resources) {
53 this.userAppService.delete(id); 78 log.info("修改第三方账号 ==>> param ==>> [updateThirdAccountStatusAndUserAppId#{}]", resources);
54 return ResultInfo.success(); 79 String username = resources.getUsername();
80 if (StringUtils.isBlank(username)) {
81 log.error("修改app账号最新登录时间失败,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources);
82 return ResultInfo.failure("修改app账号最新登录时间失败,参数错误,app账号不得为空");
83 }
84
85 String account = resources.getAccount();
86 Integer accountType = resources.getAccountType();
87 if (StringUtils.isBlank(account) || Objects.isNull(accountType)) {
88 log.error("检查app账号是否绑定了第三方账号失败, 参数错误, 第三方账号或者第三方账号类型不得为空 [checkThirdAccount# resources ==>> {}]", resources);
89 return ResultInfo.failure("检查第三方账号是否绑定了第三方账号失败, 参数错误, 第三方账号或者第三方账号类型不得为空");
90 }
91
92
93 UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
94 if (Objects.nonNull(userAppDTO.getId())) {
95 Long id = userAppDTO.getId();
96 resources.setUserAppId(id);
97 } else {
98 log.error("修改第三方账号, 参数错误, app账号不得为空 [updateValidStatusAndUserAppIdAndNickname# resources ==>> {}]", resources);
99 return ResultInfo.failure("修改第三方账号, 参数错误, app账号不得为空");
100 }
101
102 boolean result = this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources);
103 return ResultInfo.success(result);
55 } 104 }
56 105
106 @Log
107 @PostMapping(value = "/updateThirdAccountStatusAndUserAppId")
108 @ApiOperation("修改第三方账号昵称")
109 @AnonymousAccess
110 public ResultInfo updateThirdAccountNickname(@Validated @RequestBody UserAppBind resources) {
111 log.info("修改第三方账号 ==>> param ==>> [updateThirdAccountNickname#{}]", resources);
112 String account = resources.getAccount();
113 Integer accountType = resources.getAccountType();
114 if (StringUtils.isBlank(account) || Objects.isNull(accountType)) {
115 log.error("修改第三方账号昵称, 参数错误, 第三方账号或者第三方账号类型不得为空 [checkThirdAccount# resources ==>> {}]", resources);
116 return ResultInfo.failure("修改第三方账号昵称, 参数错误, 第三方账号或者第三方账号类型不得为空");
117 }
118
119 String nickname = resources.getNickname();
120 if (StringUtils.isBlank(nickname)) {
121 log.error("修改第三方账号昵称, 参数错误, 昵称不得为空 [updateThirdAccountNickname# resources ==>> {}]", resources);
122 return ResultInfo.failure("修改第三方账号昵称, 参数错误, 昵称不得为空");
123 }
124
125 boolean result = this.userAppBindService.updateThirdAccountNickname(resources);
126 return ResultInfo.success(result);
127 }
57 } 128 }
......
...@@ -20,7 +20,7 @@ public interface UserAppBindService { ...@@ -20,7 +20,7 @@ public interface UserAppBindService {
20 * 20 *
21 * @param resources 21 * @param resources
22 */ 22 */
23 void create(UserAppBind resources); 23 UserAppBindDTO create(UserAppBind resources);
24 24
25 /** 25 /**
26 * 26 *
...@@ -46,7 +46,7 @@ public interface UserAppBindService { ...@@ -46,7 +46,7 @@ public interface UserAppBindService {
46 * @param account 46 * @param account
47 * @return 47 * @return
48 */ 48 */
49 Integer cancelUserAppBind(String account); 49 boolean cancelUserAppBind(String account, Integer accountType);
50 50
51 /** 51 /**
52 * 52 *
...@@ -58,7 +58,22 @@ public interface UserAppBindService { ...@@ -58,7 +58,22 @@ public interface UserAppBindService {
58 58
59 /** 59 /**
60 * 60 *
61 * @param resources
62 * @return
63 */
64 boolean updateThirdAccount(UserAppBind resources);
65
66 /**
67 *
68 * @param resources
69 * @return
70 */
71 boolean updateThirdAccountNickname(UserAppBind resources);
72
73 /**
74 *
75 * @param resources
61 * @return 76 * @return
62 */ 77 */
63 Integer updateUserAppBind(UserAppBind userAppBind); 78 boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources);
64 } 79 }
......
1 package com.topdraw.business.module.user.app.service; 1 package com.topdraw.business.module.user.app.service;
2 2
3 import com.topdraw.business.module.user.app.domain.UserApp; 3 import com.topdraw.business.module.user.app.domain.UserApp;
4 import com.topdraw.business.module.user.app.domain.UserAppBind;
4 import com.topdraw.business.module.user.app.service.dto.UserAppDTO; 5 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
5 6
6 /** 7 /**
...@@ -25,29 +26,6 @@ public interface UserAppService { ...@@ -25,29 +26,6 @@ public interface UserAppService {
25 26
26 27
27 /** 28 /**
28 * 检查账号和秘密
29 * @param username
30 * @param password
31 * @return
32 */
33 UserAppDTO findByUsernameAndPassword(String username, String password);
34
35 /**
36 * 检查账号和验证码
37 * @param username
38 * @param VerificationCode
39 * @return
40 */
41 UserAppDTO findByUsernameAndVerificationCode(String username, String VerificationCode);
42
43 /**
44 * 检查通过第三方账号
45 * @param relationAccount
46 * @return
47 */
48 UserAppDTO findByRelationAccount(String relationAccount);
49
50 /**
51 * 29 *
52 * @param resources 30 * @param resources
53 */ 31 */
...@@ -65,4 +43,10 @@ public interface UserAppService { ...@@ -65,4 +43,10 @@ public interface UserAppService {
65 */ 43 */
66 void delete(Long id); 44 void delete(Long id);
67 45
46 /**
47 *
48 * @param resources
49 * @return
50 */
51 boolean updateLastActiveTime(UserAppBind resources);
68 } 52 }
......
...@@ -36,8 +36,9 @@ public class UserAppBindServiceImpl implements UserAppBindService { ...@@ -36,8 +36,9 @@ public class UserAppBindServiceImpl implements UserAppBindService {
36 36
37 @Override 37 @Override
38 @Transactional(rollbackFor = Exception.class) 38 @Transactional(rollbackFor = Exception.class)
39 public void create(UserAppBind resources) { 39 public UserAppBindDTO create(UserAppBind resources) {
40 this.userAppBindRepository.save(resources); 40 UserAppBind userAppBind = this.userAppBindRepository.save(resources);
41 return this.userAppBindMapper.toDto(userAppBind);
41 } 42 }
42 43
43 @Override 44 @Override
...@@ -66,8 +67,8 @@ public class UserAppBindServiceImpl implements UserAppBindService { ...@@ -66,8 +67,8 @@ public class UserAppBindServiceImpl implements UserAppBindService {
66 67
67 @Override 68 @Override
68 @Transactional(rollbackFor = Exception.class) 69 @Transactional(rollbackFor = Exception.class)
69 public Integer cancelUserAppBind(String account) { 70 public boolean cancelUserAppBind(String account, Integer accountType) {
70 return this.userAppBindRepository.cancelUserAppBind(account); 71 return this.userAppBindRepository.cancelUserAppBind(account, accountType) > 0;
71 } 72 }
72 73
73 @Override 74 @Override
...@@ -79,8 +80,20 @@ public class UserAppBindServiceImpl implements UserAppBindService { ...@@ -79,8 +80,20 @@ public class UserAppBindServiceImpl implements UserAppBindService {
79 80
80 @Override 81 @Override
81 @Transactional(rollbackFor = Exception.class) 82 @Transactional(rollbackFor = Exception.class)
82 public Integer updateUserAppBind(UserAppBind userAppBind) { 83 public boolean updateThirdAccount(UserAppBind resources) {
83 return this.userAppBindRepository.updateUserAppBind(userAppBind); 84 return this.userAppBindRepository.updateThirdAccount(resources) > 0;
85 }
86
87 @Override
88 @Transactional(rollbackFor = Exception.class)
89 public boolean updateThirdAccountNickname(UserAppBind resources) {
90 return this.userAppBindRepository.updateThirdAccountNickname(resources) > 0;
91 }
92
93 @Override
94 @Transactional(rollbackFor = Exception.class)
95 public boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources) {
96 return this.userAppBindRepository.updateValidStatusAndUserAppIdAndNickname(resources) > 0;
84 } 97 }
85 98
86 99
......
1 package com.topdraw.business.module.user.app.service.impl; 1 package com.topdraw.business.module.user.app.service.impl;
2 2
3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.domain.MemberBuilder;
5 import com.topdraw.business.module.member.domain.MemberTypeConstant;
6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.business.module.user.app.domain.UserApp; 3 import com.topdraw.business.module.user.app.domain.UserApp;
4 import com.topdraw.business.module.user.app.domain.UserAppBind;
9 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
10 import com.topdraw.business.module.user.app.repository.UserAppRepository; 6 import com.topdraw.business.module.user.app.repository.UserAppRepository;
11 import com.topdraw.business.module.user.app.service.UserAppService; 7 import com.topdraw.business.module.user.app.service.UserAppService;
...@@ -52,27 +48,6 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -52,27 +48,6 @@ public class UserAppServiceImpl implements UserAppService {
52 } 48 }
53 49
54 @Override 50 @Override
55 @Transactional(readOnly = true)
56 public UserAppDTO findByUsernameAndPassword(String username, String password) {
57 UserApp userApp = this.userAppRepository.findByUsernameAndPassword(username, password).orElseGet(UserApp::new);
58 return this.userAppMapper.toDto(userApp);
59 }
60
61 @Override
62 @Transactional(readOnly = true)
63 public UserAppDTO findByUsernameAndVerificationCode(String username, String VerificationCode) {
64 // TDDO 需要接入短信网关
65 UserApp userApp = null;
66 return this.userAppMapper.toDto(userApp);
67 }
68
69 @Override
70 @Transactional(readOnly = true)
71 public UserAppDTO findByRelationAccount(String relationAccount) {
72 return null;
73 }
74
75 @Override
76 @Transactional(rollbackFor = Exception.class) 51 @Transactional(rollbackFor = Exception.class)
77 public UserAppDTO create(UserApp resources) { 52 public UserAppDTO create(UserApp resources) {
78 UserApp userApp = this.userAppRepository.save(resources); 53 UserApp userApp = this.userAppRepository.save(resources);
...@@ -102,5 +77,11 @@ public class UserAppServiceImpl implements UserAppService { ...@@ -102,5 +77,11 @@ public class UserAppServiceImpl implements UserAppService {
102 this.userAppRepository.delete(UserApp); 77 this.userAppRepository.delete(UserApp);
103 } 78 }
104 79
80 @Override
81 @Transactional(rollbackFor = Exception.class)
82 public boolean updateLastActiveTime(UserAppBind resources) {
83 return this.userAppRepository.updateLastActiveTime(resources.getUsername()) > 0;
84 }
85
105 86
106 } 87 }
......
...@@ -10,6 +10,7 @@ import com.topdraw.business.module.common.validated.UpdateGroup; ...@@ -10,6 +10,7 @@ import com.topdraw.business.module.common.validated.UpdateGroup;
10 import com.topdraw.business.module.member.service.MemberService; 10 import com.topdraw.business.module.member.service.MemberService;
11 import com.topdraw.business.module.member.service.dto.MemberDTO; 11 import com.topdraw.business.module.member.service.dto.MemberDTO;
12 import com.topdraw.business.module.user.app.domain.UserApp; 12 import com.topdraw.business.module.user.app.domain.UserApp;
13 import com.topdraw.business.module.user.app.domain.UserAppBind;
13 import com.topdraw.business.module.user.app.service.dto.UserAppDTO; 14 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
14 import com.topdraw.business.module.user.iptv.domain.UserTv; 15 import com.topdraw.business.module.user.iptv.domain.UserTv;
15 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 16 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
...@@ -27,7 +28,6 @@ import com.topdraw.exception.GlobeExceptionMsg; ...@@ -27,7 +28,6 @@ import com.topdraw.exception.GlobeExceptionMsg;
27 import com.topdraw.resttemplate.RestTemplateClient; 28 import com.topdraw.resttemplate.RestTemplateClient;
28 import com.topdraw.util.Base64Util; 29 import com.topdraw.util.Base64Util;
29 import com.topdraw.util.JSONUtil; 30 import com.topdraw.util.JSONUtil;
30 import com.topdraw.util.RegexUtil;
31 import com.topdraw.utils.RedisUtils; 31 import com.topdraw.utils.RedisUtils;
32 import com.topdraw.weixin.util.WeChatConstants; 32 import com.topdraw.weixin.util.WeChatConstants;
33 import com.topdraw.weixin.util.WeixinUtil; 33 import com.topdraw.weixin.util.WeixinUtil;
...@@ -107,10 +107,10 @@ public class UserOperationController { ...@@ -107,10 +107,10 @@ public class UserOperationController {
107 } 107 }
108 108
109 @Log 109 @Log
110 @PostMapping(value = "/appBindUserAccount") 110 @PostMapping(value = "/appBindThirdAccount")
111 @ApiOperation("app账号绑定第三方账号") 111 @ApiOperation("app账号绑定第三方账号")
112 @AnonymousAccess 112 @AnonymousAccess
113 public ResultInfo appBindUserAccount(@Validated @RequestBody UserApp resources) { 113 public ResultInfo appBindThirdAccount(@Validated @RequestBody UserAppBind resources) {
114 log.info("app账号绑定第三方账号,参数 ==>> [appBindUserAccount#{}]", resources); 114 log.info("app账号绑定第三方账号,参数 ==>> [appBindUserAccount#{}]", resources);
115 115
116 String username = resources.getUsername(); 116 String username = resources.getUsername();
...@@ -134,7 +134,7 @@ public class UserOperationController { ...@@ -134,7 +134,7 @@ public class UserOperationController {
134 return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空"); 134 return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空");
135 } 135 }
136 136
137 boolean result = this.userOperationService.appBindUserAccount(resources); 137 boolean result = this.userOperationService.appBindThirdAccount(resources);
138 return ResultInfo.success(result); 138 return ResultInfo.success(result);
139 } 139 }
140 140
...@@ -145,21 +145,28 @@ public class UserOperationController { ...@@ -145,21 +145,28 @@ public class UserOperationController {
145 public ResultInfo updateUserApp(@Validated @RequestBody UserApp resources) { 145 public ResultInfo updateUserApp(@Validated @RequestBody UserApp resources) {
146 log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources); 146 log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources);
147 147
148 148 UserAppDTO userAppDTO = this.userOperationService.updateUserApp(resources);
149 return ResultInfo.success(); 149 return ResultInfo.success(userAppDTO);
150 } 150 }
151 151
152 @Log 152 @Log
153 @PostMapping(value = "/cancelUserAppBind") 153 @PostMapping(value = "/cancelUserAppBind")
154 @ApiOperation("取消关联第三方账号") 154 @ApiOperation("取消关联第三方账号")
155 @AnonymousAccess 155 @AnonymousAccess
156 public ResultInfo cancelUserAppBind(@Validated @RequestBody UserApp resources) { 156 public ResultInfo cancelUserAppBind(@Validated @RequestBody UserAppBind resources) {
157 log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources); 157 log.info("取消关联第三方账号, 参数 ==>> [updateUserApp#{}]", resources);
158 158
159 String account = resources.getAccount(); 159 String account = resources.getAccount();
160 if (StringUtils.isBlank(account)) { 160 if (StringUtils.isBlank(account)) {
161 log.error("参数错误,第三方账号不能为空"); 161 log.error("取消关联第三方账号失败,参数错误了,第三方账号不能为空");
162 return ResultInfo.failure("参数错误,第三方账号不能为空"); 162 return ResultInfo.failure("取消关联第三方账号失败,参数错误,第三方账号不能为空");
163 }
164
165 // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
166 Integer accountType = resources.getAccountType();
167 if (Objects.isNull(accountType)) {
168 log.error("取消关联第三方账号失败,参数错误,第三方账号类型不得为空");
169 return ResultInfo.failure("取消关联第三方账号失败,参数错误,第三方账号类型不得为空");
163 } 170 }
164 171
165 boolean result =this.userOperationService.cancelUserAppBind(resources); 172 boolean result =this.userOperationService.cancelUserAppBind(resources);
......
...@@ -2,6 +2,7 @@ package com.topdraw.business.process.service; ...@@ -2,6 +2,7 @@ package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.module.member.service.dto.MemberDTO; 3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.module.user.app.domain.UserApp; 4 import com.topdraw.business.module.user.app.domain.UserApp;
5 import com.topdraw.business.module.user.app.domain.UserAppBind;
5 import com.topdraw.business.module.user.app.service.dto.UserAppDTO; 6 import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
6 import com.topdraw.business.module.user.iptv.domain.UserTv; 7 import com.topdraw.business.module.user.iptv.domain.UserTv;
7 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 8 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
...@@ -182,13 +183,19 @@ public interface UserOperationService { ...@@ -182,13 +183,19 @@ public interface UserOperationService {
182 * @param resources 183 * @param resources
183 * @return 184 * @return
184 */ 185 */
185 boolean cancelUserAppBind(UserApp resources); 186 boolean cancelUserAppBind(UserAppBind resources);
186 187
187 /** 188 /**
188 * 189 *
189 * @param resources 190 * @param resources
190 * @return 191 * @return
191 */ 192 */
192 boolean appBindUserAccount(UserApp resources); 193 boolean appBindThirdAccount(UserAppBind resources);
193 194
195 /**
196 *
197 * @param resources
198 * @return
199 */
200 UserAppDTO updateUserApp(UserApp resources);
194 } 201 }
......
...@@ -83,10 +83,10 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -83,10 +83,10 @@ public class UserOperationServiceImpl implements UserOperationService {
83 @Autowired 83 @Autowired
84 private UserAppService userAppService; 84 private UserAppService userAppService;
85 @Autowired 85 @Autowired
86 private UserAppBindService userAppBindService;
87 @Autowired
88 private UserWeixinService userWeixinService; 86 private UserWeixinService userWeixinService;
89 @Autowired 87 @Autowired
88 private UserAppBindService userAppBindService;
89 @Autowired
90 private UserWeixinRepository userWeixinRepository; 90 private UserWeixinRepository userWeixinRepository;
91 @Autowired 91 @Autowired
92 private UserCollectionService userCollectionService; 92 private UserCollectionService userCollectionService;
...@@ -152,31 +152,40 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -152,31 +152,40 @@ public class UserOperationServiceImpl implements UserOperationService {
152 } 152 }
153 153
154 @Override 154 @Override
155 public boolean cancelUserAppBind(UserApp resources) { 155 public boolean cancelUserAppBind(UserAppBind resources) {
156 String account = resources.getAccount(); 156 String account = resources.getAccount();
157 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccount(account); 157 Integer accountType = resources.getAccountType();
158 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
158 if (Objects.nonNull(userAppBindDTO.getId())) { 159 if (Objects.nonNull(userAppBindDTO.getId())) {
159 Integer count = this.userAppBindService.cancelUserAppBind(account); 160 return this.userAppBindService.cancelUserAppBind(account, accountType);
160 if (count == 1) {
161 return true;
162 }
163 } 161 }
164 return false; 162 return false;
165 } 163 }
166 164
167 @Override 165 @Override
168 @Transactional(rollbackFor = Exception.class) 166 @Transactional(rollbackFor = Exception.class)
169 public boolean appBindUserAccount(UserApp resources) { 167 public boolean appBindThirdAccount(UserAppBind resources) {
168 String username = resources.getUsername();
169 UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
170 if (Objects.isNull(userAppDTO.getId())) {
171 return false;
172 }
173
170 String account = resources.getAccount(); 174 String account = resources.getAccount();
171 Integer accountType = resources.getAccountType(); 175 Integer accountType = resources.getAccountType();
172 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType); 176 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
173 if (Objects.nonNull(userAppBindDTO.getId())){ 177 if (Objects.nonNull(userAppBindDTO.getId())){
174 Integer count = null;//this.userAppBindService.update(account, accountType, UserAppStatusConstant.VALID_STATUS); 178 resources.setUserAppId(userAppDTO.getId());
175 return count > 0; 179 return this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources);
176 } 180 }
177 return false; 181 return false;
178 } 182 }
179 183
184 @Override
185 public UserAppDTO updateUserApp(UserApp resources) {
186 return this.userAppService.update(resources);
187 }
188
180 /** 189 /**
181 * 创建大屏账户同时创建会员 190 * 创建大屏账户同时创建会员
182 * 191 *
......