1.添加app绑定第三方账号的接口
Showing
8 changed files
with
107 additions
and
9 deletions
... | @@ -45,6 +45,10 @@ public class UserAppBind implements Serializable { | ... | @@ -45,6 +45,10 @@ public class UserAppBind implements Serializable { |
45 | @Column(name = "status", nullable = false) | 45 | @Column(name = "status", nullable = false) |
46 | private Integer status; | 46 | private Integer status; |
47 | 47 | ||
48 | // 昵称 | ||
49 | @Column(name = "nickname", nullable = false) | ||
50 | private String nickname; | ||
51 | |||
48 | // 创建时间 | 52 | // 创建时间 |
49 | @CreatedDate | 53 | @CreatedDate |
50 | @Column(name = "create_time") | 54 | @Column(name = "create_time") | ... | ... |
... | @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; | ... | @@ -5,6 +5,8 @@ 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; | 6 | import org.springframework.data.jpa.repository.Modifying; |
7 | import org.springframework.data.jpa.repository.Query; | 7 | import org.springframework.data.jpa.repository.Query; |
8 | import org.springframework.data.repository.query.Param; | ||
9 | import org.springframework.transaction.annotation.Transactional; | ||
8 | 10 | ||
9 | import java.util.Optional; | 11 | import java.util.Optional; |
10 | 12 | ||
... | @@ -19,4 +21,16 @@ public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, | ... | @@ -19,4 +21,16 @@ public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, |
19 | @Modifying | 21 | @Modifying |
20 | @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 ", nativeQuery = true) |
21 | Integer cancelUserAppBind(String account); | 23 | Integer cancelUserAppBind(String account); |
24 | |||
25 | Optional<UserAppBind> findFirstByAccountAndAccountType(String account, Integer accountType); | ||
26 | |||
27 | @Modifying | ||
28 | @Transactional(rollbackFor = Exception.class) | ||
29 | @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 1, `update_time` = now() WHERE `account` = ?1, accountType = ?2", nativeQuery = true) | ||
30 | Integer updateUserAppBindStatus2Valid(String account, Integer accountType); | ||
31 | |||
32 | @Modifying | ||
33 | @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 | Integer updateUserAppBind(@Param("resources") UserAppBind userAppBind); | ||
22 | } | 36 | } | ... | ... |
... | @@ -47,4 +47,18 @@ public interface UserAppBindService { | ... | @@ -47,4 +47,18 @@ public interface UserAppBindService { |
47 | * @return | 47 | * @return |
48 | */ | 48 | */ |
49 | Integer cancelUserAppBind(String account); | 49 | Integer cancelUserAppBind(String account); |
50 | |||
51 | /** | ||
52 | * | ||
53 | * @param account | ||
54 | * @param accountType | ||
55 | * @return | ||
56 | */ | ||
57 | UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType); | ||
58 | |||
59 | /** | ||
60 | * | ||
61 | * @return | ||
62 | */ | ||
63 | Integer updateUserAppBind(UserAppBind userAppBind); | ||
50 | } | 64 | } | ... | ... |
... | @@ -27,6 +27,9 @@ public class UserAppBindDTO implements Serializable { | ... | @@ -27,6 +27,9 @@ public class UserAppBindDTO implements Serializable { |
27 | // 绑定状态 0:解绑;1 绑定 | 27 | // 绑定状态 0:解绑;1 绑定 |
28 | private Integer status; | 28 | private Integer status; |
29 | 29 | ||
30 | // 昵称 | ||
31 | private String nickname; | ||
32 | |||
30 | // 创建时间 | 33 | // 创建时间 |
31 | private Timestamp createTime; | 34 | private Timestamp createTime; |
32 | 35 | ... | ... |
... | @@ -70,5 +70,18 @@ public class UserAppBindServiceImpl implements UserAppBindService { | ... | @@ -70,5 +70,18 @@ public class UserAppBindServiceImpl implements UserAppBindService { |
70 | return this.userAppBindRepository.cancelUserAppBind(account); | 70 | return this.userAppBindRepository.cancelUserAppBind(account); |
71 | } | 71 | } |
72 | 72 | ||
73 | @Override | ||
74 | @Transactional(readOnly = true) | ||
75 | public UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType) { | ||
76 | UserAppBind userAppBind = this.userAppBindRepository.findFirstByAccountAndAccountType(account, accountType).orElseGet(UserAppBind::new); | ||
77 | return this.userAppBindMapper.toDto(userAppBind); | ||
78 | } | ||
79 | |||
80 | @Override | ||
81 | @Transactional(rollbackFor = Exception.class) | ||
82 | public Integer updateUserAppBind(UserAppBind userAppBind) { | ||
83 | return this.userAppBindRepository.updateUserAppBind(userAppBind); | ||
84 | } | ||
85 | |||
73 | 86 | ||
74 | } | 87 | } | ... | ... |
... | @@ -107,6 +107,38 @@ public class UserOperationController { | ... | @@ -107,6 +107,38 @@ public class UserOperationController { |
107 | } | 107 | } |
108 | 108 | ||
109 | @Log | 109 | @Log |
110 | @PostMapping(value = "/appBindUserAccount") | ||
111 | @ApiOperation("app账号绑定第三方账号") | ||
112 | @AnonymousAccess | ||
113 | public ResultInfo appBindUserAccount(@Validated @RequestBody UserApp resources) { | ||
114 | log.info("app账号绑定第三方账号,参数 ==>> [appBindUserAccount#{}]", resources); | ||
115 | |||
116 | String username = resources.getUsername(); | ||
117 | if (StringUtils.isBlank(username)) { | ||
118 | log.error("app账号绑定第三方账号,参数错误,账号不得为空 "); | ||
119 | return ResultInfo.failure("app账号绑定第三方账号,参数错误,账号不得为空"); | ||
120 | } | ||
121 | |||
122 | String account = resources.getAccount(); | ||
123 | if (StringUtils.isNotBlank(account)) { | ||
124 | if (Objects.isNull(resources.getAccountType())) { | ||
125 | log.error("app账号绑定第三方账号,参数错误,第三方账号不得为空"); | ||
126 | return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号不得为空"); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号 | ||
131 | Integer accountType = resources.getAccountType(); | ||
132 | if (Objects.isNull(accountType)) { | ||
133 | log.error("app账号绑定第三方账号,参数错误,第三方账号类型不得为空"); | ||
134 | return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空"); | ||
135 | } | ||
136 | |||
137 | boolean result = this.userOperationService.appBindUserAccount(resources); | ||
138 | return ResultInfo.success(result); | ||
139 | } | ||
140 | |||
141 | @Log | ||
110 | @PostMapping(value = "/updateUserApp") | 142 | @PostMapping(value = "/updateUserApp") |
111 | @ApiOperation("修改app账号信息") | 143 | @ApiOperation("修改app账号信息") |
112 | @AnonymousAccess | 144 | @AnonymousAccess |
... | @@ -136,7 +168,7 @@ public class UserOperationController { | ... | @@ -136,7 +168,7 @@ public class UserOperationController { |
136 | 168 | ||
137 | 169 | ||
138 | @PostMapping("/appBind") | 170 | @PostMapping("/appBind") |
139 | @ApiOperation("微信小程序绑定大屏") | 171 | @ApiOperation("app绑定大屏") |
140 | @AnonymousAccess | 172 | @AnonymousAccess |
141 | public ResultInfo appBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { | 173 | public ResultInfo appBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { |
142 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources); | 174 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources); |
... | @@ -156,7 +188,7 @@ public class UserOperationController { | ... | @@ -156,7 +188,7 @@ public class UserOperationController { |
156 | } | 188 | } |
157 | 189 | ||
158 | @PostMapping("/appUnbind") | 190 | @PostMapping("/appUnbind") |
159 | @ApiOperation("小屏解绑") | 191 | @ApiOperation("app解绑") |
160 | @AnonymousAccess | 192 | @AnonymousAccess |
161 | public ResultInfo appUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { | 193 | public ResultInfo appUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { |
162 | log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); | 194 | log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); | ... | ... |
... | @@ -183,4 +183,12 @@ public interface UserOperationService { | ... | @@ -183,4 +183,12 @@ public interface UserOperationService { |
183 | * @return | 183 | * @return |
184 | */ | 184 | */ |
185 | boolean cancelUserAppBind(UserApp resources); | 185 | boolean cancelUserAppBind(UserApp resources); |
186 | |||
187 | /** | ||
188 | * | ||
189 | * @param resources | ||
190 | * @return | ||
191 | */ | ||
192 | boolean appBindUserAccount(UserApp resources); | ||
193 | |||
186 | } | 194 | } | ... | ... |
... | @@ -12,10 +12,7 @@ import com.topdraw.business.module.member.domain.MemberTypeConstant; | ... | @@ -12,10 +12,7 @@ import com.topdraw.business.module.member.domain.MemberTypeConstant; |
12 | import com.topdraw.business.module.member.service.MemberService; | 12 | import com.topdraw.business.module.member.service.MemberService; |
13 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 13 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
14 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | 14 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; |
15 | import com.topdraw.business.module.user.app.domain.UserApp; | 15 | import com.topdraw.business.module.user.app.domain.*; |
16 | import com.topdraw.business.module.user.app.domain.UserAppBind; | ||
17 | import com.topdraw.business.module.user.app.domain.UserAppBindBuilder; | ||
18 | import com.topdraw.business.module.user.app.domain.UserAppBuilder; | ||
19 | import com.topdraw.business.module.user.app.service.UserAppBindService; | 16 | import com.topdraw.business.module.user.app.service.UserAppBindService; |
20 | import com.topdraw.business.module.user.app.service.UserAppService; | 17 | import com.topdraw.business.module.user.app.service.UserAppService; |
21 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | 18 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; |
... | @@ -167,6 +164,19 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -167,6 +164,19 @@ public class UserOperationServiceImpl implements UserOperationService { |
167 | return false; | 164 | return false; |
168 | } | 165 | } |
169 | 166 | ||
167 | @Override | ||
168 | @Transactional(rollbackFor = Exception.class) | ||
169 | public boolean appBindUserAccount(UserApp resources) { | ||
170 | String account = resources.getAccount(); | ||
171 | Integer accountType = resources.getAccountType(); | ||
172 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType); | ||
173 | if (Objects.nonNull(userAppBindDTO.getId())){ | ||
174 | Integer count = null;//this.userAppBindService.update(account, accountType, UserAppStatusConstant.VALID_STATUS); | ||
175 | return count > 0; | ||
176 | } | ||
177 | return false; | ||
178 | } | ||
179 | |||
170 | /** | 180 | /** |
171 | * 创建大屏账户同时创建会员 | 181 | * 创建大屏账户同时创建会员 |
172 | * | 182 | * |
... | @@ -174,7 +184,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -174,7 +184,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
174 | * @return UserTvDTO | 184 | * @return UserTvDTO |
175 | */ | 185 | */ |
176 | @Override | 186 | @Override |
177 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 187 | @Transactional(rollbackFor = Exception.class) |
178 | public UserTvDTO createTvUserAndMember(UserTv resources) { | 188 | public UserTvDTO createTvUserAndMember(UserTv resources) { |
179 | 189 | ||
180 | // 大屏账户 | 190 | // 大屏账户 |
... | @@ -1130,7 +1140,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1130,7 +1140,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
1130 | userTv.setId(userTvDTO.getId()); | 1140 | userTv.setId(userTvDTO.getId()); |
1131 | userTv.setPriorityMemberCode(memberDTO.getCode()); | 1141 | userTv.setPriorityMemberCode(memberDTO.getCode()); |
1132 | 1142 | ||
1133 | userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); | 1143 | this.userTvService.doUpdatePriorityMemberCode(userTv); |
1134 | } | 1144 | } |
1135 | 1145 | ||
1136 | Member member = new Member(); | 1146 | Member member = new Member(); |
... | @@ -1156,7 +1166,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1156,7 +1166,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
1156 | member.setPlatformAccount(platformAccount); | 1166 | member.setPlatformAccount(platformAccount); |
1157 | 1167 | ||
1158 | // 修改会员 | 1168 | // 修改会员 |
1159 | memberDTO = this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member); | 1169 | this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member); |
1160 | 1170 | ||
1161 | memberDTO.setPlatformAccount(platformAccount); | 1171 | memberDTO.setPlatformAccount(platformAccount); |
1162 | 1172 | ... | ... |
-
Please register or sign in to post a comment