1.修复app登录逻辑
Showing
17 changed files
with
475 additions
and
23 deletions
| ... | @@ -23,6 +23,14 @@ import java.io.Serializable; | ... | @@ -23,6 +23,14 @@ import java.io.Serializable; |
| 23 | @Table(name="uc_user_app") | 23 | @Table(name="uc_user_app") |
| 24 | public class UserApp implements Serializable { | 24 | public class UserApp implements Serializable { |
| 25 | 25 | ||
| 26 | // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号 | ||
| 27 | @Transient | ||
| 28 | private Integer accountType; | ||
| 29 | |||
| 30 | // 第三方账号 | ||
| 31 | @Transient | ||
| 32 | private String account; | ||
| 33 | |||
| 26 | // ID | 34 | // ID |
| 27 | @Id | 35 | @Id |
| 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 36 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ... | ... |
| ... | @@ -41,6 +41,10 @@ public class UserAppBind implements Serializable { | ... | @@ -41,6 +41,10 @@ public class UserAppBind implements Serializable { |
| 41 | @Column(name = "user_app_id", nullable = false) | 41 | @Column(name = "user_app_id", nullable = false) |
| 42 | private Long userAppId; | 42 | private Long userAppId; |
| 43 | 43 | ||
| 44 | // 绑定状态 0:解绑;1 绑定 | ||
| 45 | @Column(name = "status", nullable = false) | ||
| 46 | private Integer status; | ||
| 47 | |||
| 44 | // 创建时间 | 48 | // 创建时间 |
| 45 | @CreatedDate | 49 | @CreatedDate |
| 46 | @Column(name = "create_time") | 50 | @Column(name = "create_time") | ... | ... |
| 1 | package com.topdraw.business.module.user.app.domain; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @author : | ||
| 5 | * @description: | ||
| 6 | * @function : | ||
| 7 | * @date :Created in 2022/6/30 13:18 | ||
| 8 | * @version: : | ||
| 9 | * @modified By: | ||
| 10 | * @since : modified in 2022/6/30 13:18 | ||
| 11 | */ | ||
| 12 | public class UserAppBindBuilder { | ||
| 13 | |||
| 14 | public static UserAppBind build(Long userAppId, String account, Integer accountType){ | ||
| 15 | UserAppBind userAppBind = new UserAppBind(); | ||
| 16 | userAppBind.setAccount(account); | ||
| 17 | userAppBind.setUserAppId(userAppId); | ||
| 18 | userAppBind.setAccountType(accountType); | ||
| 19 | userAppBind.setStatus(UserAppStatusConstant.VALID_STATUS); | ||
| 20 | return userAppBind; | ||
| 21 | } | ||
| 22 | |||
| 23 | } |
| 1 | package com.topdraw.business.module.user.app.domain; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @author : | ||
| 5 | * @description: | ||
| 6 | * @function : | ||
| 7 | * @date :Created in 2022/6/30 11:42 | ||
| 8 | * @version: : | ||
| 9 | * @modified By: | ||
| 10 | * @since : modified in 2022/6/30 11:42 | ||
| 11 | */ | ||
| 12 | public interface UserAppBindStatusConstant { | ||
| 13 | // 绑定状态 0:解绑;1 绑定 | ||
| 14 | Integer VALID_STATUS = 1; | ||
| 15 | Integer INVALID_STATUS = 0; | ||
| 16 | |||
| 17 | } |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/domain/UserAppBuilder.java
0 → 100644
| 1 | package com.topdraw.business.module.user.app.domain; | ||
| 2 | |||
| 3 | import com.topdraw.util.TimestampUtil; | ||
| 4 | import org.apache.commons.lang3.StringUtils; | ||
| 5 | import org.springframework.beans.BeanUtils; | ||
| 6 | |||
| 7 | import java.util.Objects; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author : | ||
| 11 | * @description: | ||
| 12 | * @function : | ||
| 13 | * @date :Created in 2022/6/30 11:35 | ||
| 14 | * @version: : | ||
| 15 | * @modified By: | ||
| 16 | * @since : modified in 2022/6/30 11:35 | ||
| 17 | */ | ||
| 18 | public class UserAppBuilder { | ||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | public static UserApp build(Long memberId, UserApp resource){ | ||
| 23 | |||
| 24 | UserApp userApp = new UserApp(); | ||
| 25 | userApp.setId(null); | ||
| 26 | userApp.setMemberId(memberId); | ||
| 27 | userApp.setUsername(resource.getUsername()); | ||
| 28 | userApp.setTags(resource.getTags()); | ||
| 29 | userApp.setLastActiveTime(TimestampUtil.now()); | ||
| 30 | userApp.setEmail(resource.getEmail()); | ||
| 31 | userApp.setType(Objects.isNull(resource.getType()) ? resource.getType() : -1); | ||
| 32 | userApp.setNickname(StringUtils.isNotBlank(resource.getNickname()) ? resource.getNickname() : resource.getUsername()); | ||
| 33 | userApp.setPassword(resource.getPassword()); | ||
| 34 | userApp.setCellphone(StringUtils.isNotBlank(resource.getCellphone()) ? resource.getCellphone() : resource.getUsername()); | ||
| 35 | userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : "1900-01-01"); | ||
| 36 | userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : 0); | ||
| 37 | userApp.setStatus(UserAppStatusConstant.VALID_STATUS); | ||
| 38 | userApp.setCreateTime(null); | ||
| 39 | userApp.setUpdateTime(null); | ||
| 40 | return userApp; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | } |
| 1 | package com.topdraw.business.module.user.app.domain; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @author : | ||
| 5 | * @description: | ||
| 6 | * @function : | ||
| 7 | * @date :Created in 2022/6/30 11:42 | ||
| 8 | * @version: : | ||
| 9 | * @modified By: | ||
| 10 | * @since : modified in 2022/6/30 11:42 | ||
| 11 | */ | ||
| 12 | public interface UserAppStatusConstant { | ||
| 13 | // 状态 0:禁用;1:生效;-1:注销 | ||
| 14 | Integer VALID_STATUS = 1; | ||
| 15 | Integer FORBID_STATUS = 0; | ||
| 16 | Integer INVALID_STATUS = -1; | ||
| 17 | |||
| 18 | } |
| ... | @@ -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.UserAppBind; | 3 | import com.topdraw.business.module.user.app.domain.UserAppBind; |
| 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 | ||
| ... | @@ -12,4 +14,9 @@ import java.util.Optional; | ... | @@ -12,4 +14,9 @@ import java.util.Optional; |
| 12 | */ | 14 | */ |
| 13 | public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, JpaSpecificationExecutor<UserAppBind> { | 15 | public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, JpaSpecificationExecutor<UserAppBind> { |
| 14 | 16 | ||
| 17 | Optional<UserAppBind> findFirstByAccount(String account); | ||
| 18 | |||
| 19 | @Modifying | ||
| 20 | @Query(value = "UPDATE `uc_user_app_bind` SET `status` = 0 , `update_time` = now() WHERE `account` = ?1 ", nativeQuery = true) | ||
| 21 | Integer cancelUserAppBind(String account); | ||
| 15 | } | 22 | } | ... | ... |
| ... | @@ -34,4 +34,17 @@ public interface UserAppBindService { | ... | @@ -34,4 +34,17 @@ public interface UserAppBindService { |
| 34 | */ | 34 | */ |
| 35 | void delete(Long id); | 35 | void delete(Long id); |
| 36 | 36 | ||
| 37 | /** | ||
| 38 | * | ||
| 39 | * @param account | ||
| 40 | * @return | ||
| 41 | */ | ||
| 42 | UserAppBindDTO findFirstByAccount(String account); | ||
| 43 | |||
| 44 | /** | ||
| 45 | * | ||
| 46 | * @param account | ||
| 47 | * @return | ||
| 48 | */ | ||
| 49 | Integer cancelUserAppBind(String account); | ||
| 37 | } | 50 | } | ... | ... |
| ... | @@ -24,6 +24,9 @@ public class UserAppBindDTO implements Serializable { | ... | @@ -24,6 +24,9 @@ public class UserAppBindDTO implements Serializable { |
| 24 | // app账号id | 24 | // app账号id |
| 25 | private Long userAppId; | 25 | private Long userAppId; |
| 26 | 26 | ||
| 27 | // 绑定状态 0:解绑;1 绑定 | ||
| 28 | private Integer status; | ||
| 29 | |||
| 27 | // 创建时间 | 30 | // 创建时间 |
| 28 | private Timestamp createTime; | 31 | private Timestamp createTime; |
| 29 | 32 | ... | ... |
| ... | @@ -11,14 +11,7 @@ import org.springframework.stereotype.Service; | ... | @@ -11,14 +11,7 @@ import org.springframework.stereotype.Service; |
| 11 | import org.springframework.transaction.annotation.Propagation; | 11 | import org.springframework.transaction.annotation.Propagation; |
| 12 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
| 13 | import org.springframework.dao.EmptyResultDataAccessException; | 13 | import org.springframework.dao.EmptyResultDataAccessException; |
| 14 | import org.springframework.data.domain.Page; | ||
| 15 | import org.springframework.data.domain.Pageable; | ||
| 16 | import org.springframework.util.Assert; | 14 | import org.springframework.util.Assert; |
| 17 | import com.topdraw.utils.PageUtil; | ||
| 18 | import com.topdraw.utils.QueryHelp; | ||
| 19 | |||
| 20 | import java.util.List; | ||
| 21 | import java.util.Map; | ||
| 22 | 15 | ||
| 23 | /** | 16 | /** |
| 24 | * @author XiangHan | 17 | * @author XiangHan |
| ... | @@ -65,5 +58,17 @@ public class UserAppBindServiceImpl implements UserAppBindService { | ... | @@ -65,5 +58,17 @@ public class UserAppBindServiceImpl implements UserAppBindService { |
| 65 | this.userAppBindRepository.delete(UserAppBind); | 58 | this.userAppBindRepository.delete(UserAppBind); |
| 66 | } | 59 | } |
| 67 | 60 | ||
| 61 | @Override | ||
| 62 | public UserAppBindDTO findFirstByAccount(String account) { | ||
| 63 | UserAppBind userAppBind = this.userAppBindRepository.findFirstByAccount(account).orElseGet(UserAppBind::new); | ||
| 64 | return this.userAppBindMapper.toDto(userAppBind); | ||
| 65 | } | ||
| 66 | |||
| 67 | @Override | ||
| 68 | @Transactional(rollbackFor = Exception.class) | ||
| 69 | public Integer cancelUserAppBind(String account) { | ||
| 70 | return this.userAppBindRepository.cancelUserAppBind(account); | ||
| 71 | } | ||
| 72 | |||
| 68 | 73 | ||
| 69 | } | 74 | } | ... | ... |
| ... | @@ -24,13 +24,17 @@ public class UserTvBuilder { | ... | @@ -24,13 +24,17 @@ public class UserTvBuilder { |
| 24 | private static final String DEFAULT_CREATE_BY = "system"; | 24 | private static final String DEFAULT_CREATE_BY = "system"; |
| 25 | private static final String DEFAULT_UPDATE_BY = "system"; | 25 | private static final String DEFAULT_UPDATE_BY = "system"; |
| 26 | 26 | ||
| 27 | public static UserTv build(Long memberId, String memberCode, UserTv userTv){ | 27 | |
| 28 | |||
| 29 | public static UserTv build(Long memberId, String memberCode , UserTv userTv){ | ||
| 28 | return build(memberId,memberCode,userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(), | 30 | return build(memberId,memberCode,userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(), |
| 29 | userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId(), userTv.getPlatform()); | 31 | userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy(), userTv.getVisUserId(), |
| 32 | userTv.getPlatform(), userTv.getPassword(), userTv.getGroups()); | ||
| 30 | } | 33 | } |
| 31 | 34 | ||
| 32 | public static UserTv build(Long memberId , String memberCode , Long id , String platformAccount , String nickname , String username, | 35 | public static UserTv build(Long memberId , String memberCode , Long id , String platformAccount , String nickname , String username, |
| 33 | Integer loginDays , Integer status ,Integer continueDays , String createBy , String updateBy,Long visUserId, String platform){ | 36 | Integer loginDays , Integer status ,Integer continueDays , String createBy , String updateBy,Long visUserId, |
| 37 | String platform, String password, String groups){ | ||
| 34 | Assert.notNull(memberId,GlobeExceptionMsg.MEMBER_ID_IS_NULL); | 38 | Assert.notNull(memberId,GlobeExceptionMsg.MEMBER_ID_IS_NULL); |
| 35 | Assert.notNull(memberCode,GlobeExceptionMsg.MEMBER_CODE_IS_NULL); | 39 | Assert.notNull(memberCode,GlobeExceptionMsg.MEMBER_CODE_IS_NULL); |
| 36 | Assert.notNull(platformAccount,GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); | 40 | Assert.notNull(platformAccount,GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); |
| ... | @@ -45,6 +49,8 @@ public class UserTvBuilder { | ... | @@ -45,6 +49,8 @@ public class UserTvBuilder { |
| 45 | userTv.setMemberId(memberId); | 49 | userTv.setMemberId(memberId); |
| 46 | userTv.setNickname(StringUtils.isBlank(nickname)?platformAccount:nickname); | 50 | userTv.setNickname(StringUtils.isBlank(nickname)?platformAccount:nickname); |
| 47 | userTv.setUsername(StringUtils.isBlank(username)?platformAccount:username); | 51 | userTv.setUsername(StringUtils.isBlank(username)?platformAccount:username); |
| 52 | userTv.setPassword(password); | ||
| 53 | userTv.setGroups(groups); | ||
| 48 | userTv.setLoginDays(Objects.nonNull(loginDays)?loginDays:DEFAULT_VALUE); | 54 | userTv.setLoginDays(Objects.nonNull(loginDays)?loginDays:DEFAULT_VALUE); |
| 49 | userTv.setLoginType(DEFAULT_VALUE); | 55 | userTv.setLoginType(DEFAULT_VALUE); |
| 50 | userTv.setStatus(Objects.nonNull(status)?status:DEFAULT_VALUE); | 56 | userTv.setStatus(Objects.nonNull(status)?status:DEFAULT_VALUE); | ... | ... |
| ... | @@ -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.service.dto.UserAppDTO; | ||
| 13 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 14 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 14 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 15 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
| 15 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 16 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| ... | @@ -26,6 +27,7 @@ import com.topdraw.exception.GlobeExceptionMsg; | ... | @@ -26,6 +27,7 @@ import com.topdraw.exception.GlobeExceptionMsg; |
| 26 | import com.topdraw.resttemplate.RestTemplateClient; | 27 | import com.topdraw.resttemplate.RestTemplateClient; |
| 27 | import com.topdraw.util.Base64Util; | 28 | import com.topdraw.util.Base64Util; |
| 28 | import com.topdraw.util.JSONUtil; | 29 | import com.topdraw.util.JSONUtil; |
| 30 | import com.topdraw.util.RegexUtil; | ||
| 29 | import com.topdraw.utils.RedisUtils; | 31 | import com.topdraw.utils.RedisUtils; |
| 30 | import com.topdraw.weixin.util.WeChatConstants; | 32 | import com.topdraw.weixin.util.WeChatConstants; |
| 31 | import com.topdraw.weixin.util.WeixinUtil; | 33 | import com.topdraw.weixin.util.WeixinUtil; |
| ... | @@ -35,6 +37,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -35,6 +37,7 @@ import lombok.extern.slf4j.Slf4j; |
| 35 | import org.apache.commons.lang3.StringUtils; | 37 | import org.apache.commons.lang3.StringUtils; |
| 36 | import org.springframework.beans.factory.annotation.Autowired; | 38 | import org.springframework.beans.factory.annotation.Autowired; |
| 37 | import org.springframework.util.Assert; | 39 | import org.springframework.util.Assert; |
| 40 | import org.springframework.util.Base64Utils; | ||
| 38 | import org.springframework.validation.annotation.Validated; | 41 | import org.springframework.validation.annotation.Validated; |
| 39 | import org.springframework.web.bind.annotation.*; | 42 | import org.springframework.web.bind.annotation.*; |
| 40 | 43 | ||
| ... | @@ -69,14 +72,38 @@ public class UserOperationController { | ... | @@ -69,14 +72,38 @@ public class UserOperationController { |
| 69 | /******************************************************* APP ************************************/ | 72 | /******************************************************* APP ************************************/ |
| 70 | 73 | ||
| 71 | @Log | 74 | @Log |
| 72 | @PostMapping(value = "/appLogin") | 75 | @PostMapping(value = "/appRegister") |
| 73 | @ApiOperation("app登录") | 76 | @ApiOperation("app注册") |
| 74 | @AnonymousAccess | 77 | @AnonymousAccess |
| 75 | public ResultInfo appLogin(@Validated @RequestBody UserApp resources) { | 78 | public ResultInfo appRegister(@Validated @RequestBody UserApp resources) { |
| 76 | log.info("app登录 ==>> param ==>> [appLogin#{}]", resources); | 79 | log.info("app注册 ==>> param ==>> [appRegister#{}]", resources); |
| 77 | 80 | ||
| 78 | UserTvDTO userTvDTO = this.userOperationService.appLogin(resources); | 81 | String username = resources.getUsername(); |
| 79 | return ResultInfo.success(); | 82 | if (StringUtils.isBlank(username)) { |
| 83 | log.error("app注册,参数错误,账号不得为空 "); | ||
| 84 | return ResultInfo.failure("app注册,参数错误,账号不得为空"); | ||
| 85 | } | ||
| 86 | |||
| 87 | Integer type = resources.getType(); | ||
| 88 | if (Objects.isNull(type)) { | ||
| 89 | log.error("app注册,参数错误,账号类型不得为空 "); | ||
| 90 | return ResultInfo.failure("app注册,参数错误,账号类型不得为空"); | ||
| 91 | } | ||
| 92 | |||
| 93 | String account = resources.getAccount(); | ||
| 94 | if (StringUtils.isNotBlank(account)) { | ||
| 95 | if (Objects.isNull(resources.getAccountType())) { | ||
| 96 | log.error("app注册,参数错误,第三方账号类型不得为空"); | ||
| 97 | return ResultInfo.failure("app注册,参数错误,第三方账号类型不得为空"); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | if (StringUtils.isBlank(resources.getNickname())) { | ||
| 102 | resources.setNickname(Base64Utils.encodeToString(username.getBytes())); | ||
| 103 | } | ||
| 104 | |||
| 105 | UserAppDTO userAppDTO = this.userOperationService.appRegister(resources); | ||
| 106 | return ResultInfo.success(userAppDTO); | ||
| 80 | } | 107 | } |
| 81 | 108 | ||
| 82 | @Log | 109 | @Log |
| ... | @@ -86,10 +113,28 @@ public class UserOperationController { | ... | @@ -86,10 +113,28 @@ public class UserOperationController { |
| 86 | public ResultInfo updateUserApp(@Validated @RequestBody UserApp resources) { | 113 | public ResultInfo updateUserApp(@Validated @RequestBody UserApp resources) { |
| 87 | log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources); | 114 | log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources); |
| 88 | 115 | ||
| 89 | this.userOperationService.appLogin(resources); | 116 | |
| 90 | return ResultInfo.success(); | 117 | return ResultInfo.success(); |
| 91 | } | 118 | } |
| 92 | 119 | ||
| 120 | @Log | ||
| 121 | @PostMapping(value = "/cancelUserAppBind") | ||
| 122 | @ApiOperation("取消关联第三方账号") | ||
| 123 | @AnonymousAccess | ||
| 124 | public ResultInfo cancelUserAppBind(@Validated @RequestBody UserApp resources) { | ||
| 125 | log.info("修改app账号信息 ==>> param ==>> [updateUserApp#{}]", resources); | ||
| 126 | |||
| 127 | String account = resources.getAccount(); | ||
| 128 | if (StringUtils.isBlank(account)) { | ||
| 129 | log.error("参数错误,第三方账号不能为空"); | ||
| 130 | return ResultInfo.failure("参数错误,第三方账号不能为空"); | ||
| 131 | } | ||
| 132 | |||
| 133 | boolean result =this.userOperationService.cancelUserAppBind(resources); | ||
| 134 | return ResultInfo.success(result); | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 93 | @PostMapping("/appBind") | 138 | @PostMapping("/appBind") |
| 94 | @ApiOperation("微信小程序绑定大屏") | 139 | @ApiOperation("微信小程序绑定大屏") |
| 95 | @AnonymousAccess | 140 | @AnonymousAccess | ... | ... |
| ... | @@ -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.service.dto.UserAppDTO; | ||
| 5 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 6 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 6 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 7 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
| 7 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 8 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| ... | @@ -168,10 +169,18 @@ public interface UserOperationService { | ... | @@ -168,10 +169,18 @@ public interface UserOperationService { |
| 168 | */ | 169 | */ |
| 169 | UserTvDTO updateUserTv(UserTv resources); | 170 | UserTvDTO updateUserTv(UserTv resources); |
| 170 | 171 | ||
| 172 | |||
| 171 | /** | 173 | /** |
| 172 | * | 174 | * |
| 173 | * @param resources | 175 | * @param resources |
| 176 | * @return | ||
| 174 | */ | 177 | */ |
| 175 | UserTvDTO appLogin(UserApp resources); | 178 | UserAppDTO appRegister(UserApp resources); |
| 176 | 179 | ||
| 180 | /** | ||
| 181 | * | ||
| 182 | * @param resources | ||
| 183 | * @return | ||
| 184 | */ | ||
| 185 | boolean cancelUserAppBind(UserApp resources); | ||
| 177 | } | 186 | } | ... | ... |
| ... | @@ -8,11 +8,17 @@ import com.alibaba.fastjson.JSONObject; | ... | @@ -8,11 +8,17 @@ import com.alibaba.fastjson.JSONObject; |
| 8 | import com.topdraw.aspect.AsyncMqSend; | 8 | import com.topdraw.aspect.AsyncMqSend; |
| 9 | import com.topdraw.business.module.member.domain.Member; | 9 | import com.topdraw.business.module.member.domain.Member; |
| 10 | import com.topdraw.business.module.member.domain.MemberBuilder; | 10 | import com.topdraw.business.module.member.domain.MemberBuilder; |
| 11 | import com.topdraw.business.module.member.domain.MemberTypeConstant; | ||
| 11 | import com.topdraw.business.module.member.service.MemberService; | 12 | import com.topdraw.business.module.member.service.MemberService; |
| 12 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 13 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 13 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | 14 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; |
| 14 | import com.topdraw.business.module.user.app.domain.UserApp; | 15 | import com.topdraw.business.module.user.app.domain.UserApp; |
| 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; | ||
| 15 | import com.topdraw.business.module.user.app.service.UserAppService; | 20 | import com.topdraw.business.module.user.app.service.UserAppService; |
| 21 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | ||
| 16 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; | 22 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; |
| 17 | import com.topdraw.business.module.user.iptv.domain.UserConstant; | 23 | import com.topdraw.business.module.user.iptv.domain.UserConstant; |
| 18 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 24 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| ... | @@ -55,7 +61,6 @@ import org.springframework.aop.framework.AopContext; | ... | @@ -55,7 +61,6 @@ import org.springframework.aop.framework.AopContext; |
| 55 | import org.springframework.beans.BeanUtils; | 61 | import org.springframework.beans.BeanUtils; |
| 56 | import org.springframework.beans.factory.annotation.Autowired; | 62 | import org.springframework.beans.factory.annotation.Autowired; |
| 57 | import org.springframework.beans.factory.annotation.Value; | 63 | import org.springframework.beans.factory.annotation.Value; |
| 58 | import org.springframework.cache.annotation.CachePut; | ||
| 59 | import org.springframework.data.domain.PageRequest; | 64 | import org.springframework.data.domain.PageRequest; |
| 60 | import org.springframework.data.domain.Sort; | 65 | import org.springframework.data.domain.Sort; |
| 61 | import org.springframework.stereotype.Service; | 66 | import org.springframework.stereotype.Service; |
| ... | @@ -81,6 +86,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -81,6 +86,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 81 | @Autowired | 86 | @Autowired |
| 82 | private UserAppService userAppService; | 87 | private UserAppService userAppService; |
| 83 | @Autowired | 88 | @Autowired |
| 89 | private UserAppBindService userAppBindService; | ||
| 90 | @Autowired | ||
| 84 | private UserWeixinService userWeixinService; | 91 | private UserWeixinService userWeixinService; |
| 85 | @Autowired | 92 | @Autowired |
| 86 | private UserWeixinRepository userWeixinRepository; | 93 | private UserWeixinRepository userWeixinRepository; |
| ... | @@ -115,17 +122,51 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -115,17 +122,51 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 115 | 122 | ||
| 116 | @Override | 123 | @Override |
| 117 | @Transactional(rollbackFor = Exception.class) | 124 | @Transactional(rollbackFor = Exception.class) |
| 118 | public UserTvDTO appLogin(UserApp resources) { | 125 | public UserAppDTO appRegister(UserApp resources) { |
| 126 | |||
| 127 | UserAppDTO userAppDTO = this.userAppService.findByUsername(resources.getUsername()); | ||
| 128 | if (Objects.isNull(userAppDTO.getId())) { | ||
| 129 | |||
| 130 | // 先创建会员 | ||
| 131 | Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getHeadimgurl(), resources.getNickname(), 0); | ||
| 132 | MemberDTO memberDTO = this.memberService.create(member); | ||
| 133 | |||
| 134 | if (Objects.nonNull(memberDTO.getId())) { | ||
| 135 | |||
| 136 | // 保存app账号 | ||
| 137 | UserAppDTO _userAppDTO = this.userAppService.create(UserAppBuilder.build(memberDTO.getId(), resources)); | ||
| 138 | |||
| 139 | if (Objects.nonNull(_userAppDTO.getId()) && StringUtils.isNotBlank(resources.getAccount())) { | ||
| 140 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccount(resources.getAccount()); | ||
| 141 | if (Objects.isNull(userAppBindDTO.getId())) { | ||
| 142 | // 保存绑定关系 | ||
| 143 | UserAppBind userAppBind = UserAppBindBuilder.build(_userAppDTO.getId(), resources.getAccount(), resources.getAccountType()); | ||
| 144 | this.userAppBindService.create(userAppBind); | ||
| 145 | } | ||
| 146 | } | ||
| 119 | 147 | ||
| 120 | String username = resources.getUsername(); | 148 | return _userAppDTO; |
| 121 | UserAppDTO userAppDTO = this.userAppService.findByUsername(username); | 149 | |
| 122 | if (Objects.nonNull(userAppDTO)) { | 150 | } |
| 123 | 151 | ||
| 124 | } | 152 | } |
| 125 | 153 | ||
| 126 | return null; | 154 | return null; |
| 127 | } | 155 | } |
| 128 | 156 | ||
| 157 | @Override | ||
| 158 | public boolean cancelUserAppBind(UserApp resources) { | ||
| 159 | String account = resources.getAccount(); | ||
| 160 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccount(account); | ||
| 161 | if (Objects.nonNull(userAppBindDTO.getId())) { | ||
| 162 | Integer count = this.userAppBindService.cancelUserAppBind(account); | ||
| 163 | if (count == 1) { | ||
| 164 | return true; | ||
| 165 | } | ||
| 166 | } | ||
| 167 | return false; | ||
| 168 | } | ||
| 169 | |||
| 129 | /** | 170 | /** |
| 130 | * 创建大屏账户同时创建会员 | 171 | * 创建大屏账户同时创建会员 |
| 131 | * | 172 | * | ... | ... |
| 1 | package com.topdraw.util; | ||
| 2 | |||
| 3 | /* | ||
| 4 | import java.security.NoSuchAlgorithmException; | ||
| 5 | import java.security.SecureRandom; | ||
| 6 | import java.util.UUID; | ||
| 7 | |||
| 8 | import org.afflatus.utility.AppConfiguration; | ||
| 9 | import org.slf4j.Logger; | ||
| 10 | import org.slf4j.LoggerFactory; | ||
| 11 | |||
| 12 | import com.aliyun.mns.client.CloudAccount; | ||
| 13 | import com.aliyun.mns.client.CloudTopic; | ||
| 14 | import com.aliyun.mns.client.MNSClient; | ||
| 15 | import com.aliyun.mns.common.ServiceException; | ||
| 16 | import com.aliyun.mns.model.BatchSmsAttributes; | ||
| 17 | import com.aliyun.mns.model.MessageAttributes; | ||
| 18 | import com.aliyun.mns.model.RawTopicMessage; | ||
| 19 | import com.aliyun.mns.model.TopicMessage; | ||
| 20 | import com.aliyuncs.DefaultAcsClient; | ||
| 21 | import com.aliyuncs.IAcsClient; | ||
| 22 | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; | ||
| 23 | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; | ||
| 24 | import com.aliyuncs.http.MethodType; | ||
| 25 | import com.aliyuncs.profile.DefaultProfile; | ||
| 26 | import com.aliyuncs.profile.IClientProfile; | ||
| 27 | */ | ||
| 28 | |||
| 29 | public class MsgUtil { | ||
| 30 | |||
| 31 | // private static Logger log = LoggerFactory.getLogger(MsgUtil.class.getName()); | ||
| 32 | |||
| 33 | /* private static final String ACCESSID = AppConfiguration.get("MESSAGE.ACCESSID"); | ||
| 34 | private static final String ACCESSKEY = AppConfiguration.get("MESSAGE.ACCESSKEY"); | ||
| 35 | private static final String MNSENDPOINT = AppConfiguration.get("MESSAGE.MNSENDPOINT"); | ||
| 36 | private static final String TOPIC = AppConfiguration.get("MESSAGE.TOPIC"); | ||
| 37 | private static final String SIGNNAME = AppConfiguration.get("MESSAGE.SIGNNAME"); | ||
| 38 | private static final String TEMPLATECODE = AppConfiguration.get("MESSAGE.TEMPLATECODE"); | ||
| 39 | private static final String REGION = AppConfiguration.get("MESSAGE.REGION"); | ||
| 40 | |||
| 41 | public static String generateVerifyCodeAndSend(String verifyKey, String phone) { | ||
| 42 | String verifyCode; | ||
| 43 | try { | ||
| 44 | verifyCode = getRandom(4); | ||
| 45 | } catch (NoSuchAlgorithmException e) { | ||
| 46 | verifyCode = "8673"; | ||
| 47 | } | ||
| 48 | // sendMsg(phone, ":" + verifyCode + ",序号:" + verifyKey); | ||
| 49 | sendMsg2(phone, verifyCode); | ||
| 50 | return verifyCode; | ||
| 51 | }*/ | ||
| 52 | |||
| 53 | public static void sendMsg(String phone, String verifyCode) { | ||
| 54 | /** | ||
| 55 | * Step 1. 获取主题引用 | ||
| 56 | */ | ||
| 57 | /*CloudAccount account = new CloudAccount(ACCESSID, ACCESSKEY, MNSENDPOINT); | ||
| 58 | MNSClient client = account.getMNSClient(); | ||
| 59 | CloudTopic topic = client.getTopicRef(TOPIC);*/ | ||
| 60 | /** | ||
| 61 | * Step 2. 设置SMS消息体(必须) | ||
| 62 | * | ||
| 63 | * 注:目前暂时不支持消息内容为空,需要指定消息内容,不为空即可。 | ||
| 64 | */ | ||
| 65 | /*RawTopicMessage msg = new RawTopicMessage(); | ||
| 66 | msg.setMessageBody("sms-message");*/ | ||
| 67 | /** | ||
| 68 | * Step 3. 生成SMS消息属性 | ||
| 69 | */ | ||
| 70 | /*MessageAttributes messageAttributes = new MessageAttributes(); | ||
| 71 | BatchSmsAttributes batchSmsAttributes = new BatchSmsAttributes(); | ||
| 72 | // 3.1 设置发送短信的签名(SMSSignName) | ||
| 73 | batchSmsAttributes.setFreeSignName(SIGNNAME); | ||
| 74 | // 3.2 设置发送短信使用的模板(SMSTempateCode) | ||
| 75 | batchSmsAttributes.setTemplateCode(TEMPLATECODE); | ||
| 76 | // 3.3 设置发送短信所使用的模板中参数对应的值(在短信模板中定义的,没有可以不用设置) | ||
| 77 | BatchSmsAttributes.SmsReceiverParams smsReceiverParams = new BatchSmsAttributes.SmsReceiverParams(); | ||
| 78 | smsReceiverParams.setParam("code", verifyCode); | ||
| 79 | // 3.4 增加接收短信的号码 | ||
| 80 | batchSmsAttributes.addSmsReceiver(phone, smsReceiverParams); | ||
| 81 | messageAttributes.setBatchSmsAttributes(batchSmsAttributes);*/ | ||
| 82 | // try { | ||
| 83 | /** | ||
| 84 | * Step 4. 发布SMS消息 | ||
| 85 | */ | ||
| 86 | /*TopicMessage ret = topic.publishMessage(msg, messageAttributes); | ||
| 87 | log.info("sendMsg | MessageId: " + ret.getMessageId() + " MessageMD5: " + ret.getMessageBodyMD5()); | ||
| 88 | } catch (ServiceException se) { | ||
| 89 | System.out.println(se.getErrorCode() + se.getRequestId()); | ||
| 90 | System.out.println(se.getMessage()); | ||
| 91 | se.printStackTrace(); | ||
| 92 | } catch (Exception e) { | ||
| 93 | e.printStackTrace(); | ||
| 94 | } finally { | ||
| 95 | client.close(); | ||
| 96 | }*/ | ||
| 97 | } | ||
| 98 | |||
| 99 | public static void sendMsg2(String phone, String verifyCode) { | ||
| 100 | /* | ||
| 101 | try { | ||
| 102 | // 设置超时时间-可自行调整 | ||
| 103 | System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); | ||
| 104 | System.setProperty("sun.net.client.defaultReadTimeout", "10000"); | ||
| 105 | // 初始化ascClient需要的几个参数 | ||
| 106 | final String product = "Dysmsapi";// 短信API产品名称(短信产品名固定,无需修改) | ||
| 107 | final String domain = "dysmsapi.aliyuncs.com";// 短信API产品域名(接口地址固定,无需修改) | ||
| 108 | // 替换成你的AK | ||
| 109 | final String accessKeyId = ACCESSID;// 你的accessKeyId,参考本文档步骤2 | ||
| 110 | final String accessKeySecret = ACCESSKEY;// 你的accessKeySecret,参考本文档步骤2 | ||
| 111 | // 初始化ascClient,暂时不支持多region(请勿修改) | ||
| 112 | IClientProfile profile = DefaultProfile.getProfile(REGION, accessKeyId, accessKeySecret); | ||
| 113 | DefaultProfile.addEndpoint(REGION, REGION, product, domain); | ||
| 114 | IAcsClient acsClient = new DefaultAcsClient(profile); | ||
| 115 | // 组装请求对象 | ||
| 116 | SendSmsRequest request = new SendSmsRequest(); | ||
| 117 | // 使用post提交 | ||
| 118 | request.setMethod(MethodType.POST); | ||
| 119 | // 必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式 | ||
| 120 | request.setPhoneNumbers(phone); | ||
| 121 | // 必填:短信签名-可在短信控制台中找到 | ||
| 122 | request.setSignName(SIGNNAME); | ||
| 123 | // 必填:短信模板-可在短信控制台中找到 | ||
| 124 | request.setTemplateCode(TEMPLATECODE); | ||
| 125 | // 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 | ||
| 126 | // 友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败 | ||
| 127 | request.setTemplateParam("{\"code\":\"" + verifyCode + "\"}"); | ||
| 128 | // 可选-上行短信扩展码(扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段) | ||
| 129 | // request.setSmsUpExtendCode("90997"); | ||
| 130 | // 可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 | ||
| 131 | request.setOutId(UUID.randomUUID().toString().replaceAll("-", "")); | ||
| 132 | // 请求失败这里会抛ClientException异常 | ||
| 133 | SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); | ||
| 134 | if (null != sendSmsResponse) { | ||
| 135 | log.info("sendMsg | RequestId: " + sendSmsResponse.getRequestId() + " Code: " | ||
| 136 | + sendSmsResponse.getCode() + " Message: " + sendSmsResponse.getMessage()); | ||
| 137 | } | ||
| 138 | if (sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) { | ||
| 139 | // 请求成功 | ||
| 140 | } | ||
| 141 | } catch (Exception e) { | ||
| 142 | e.printStackTrace(); | ||
| 143 | } finally { | ||
| 144 | |||
| 145 | } | ||
| 146 | */ | ||
| 147 | |||
| 148 | } | ||
| 149 | |||
| 150 | /*public static String getRandom(int count) throws NoSuchAlgorithmException { | ||
| 151 | StringBuilder sb = new StringBuilder(); | ||
| 152 | String str = "0123456789"; | ||
| 153 | SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); | ||
| 154 | for (int i = 0; i < count; i++) { | ||
| 155 | int num = sr.nextInt(str.length()); | ||
| 156 | sb.append(str.charAt(num)); | ||
| 157 | str = str.replace(("" + str.charAt(num)), ""); | ||
| 158 | } | ||
| 159 | return sb.toString(); | ||
| 160 | } | ||
| 161 | */ | ||
| 162 | } |
| 1 | package com.topdraw.util; | ||
| 2 | |||
| 3 | import java.util.regex.Matcher; | ||
| 4 | import java.util.regex.Pattern; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * @author : | ||
| 8 | * @description: | ||
| 9 | * @function : | ||
| 10 | * @date :Created in 2022/6/29 15:10 | ||
| 11 | * @version: : | ||
| 12 | * @modified By: | ||
| 13 | * @since : modified in 2022/6/29 15:10 | ||
| 14 | */ | ||
| 15 | public class RegexUtil { | ||
| 16 | |||
| 17 | |||
| 18 | public static boolean mobileRegex(String mobile){ | ||
| 19 | // String pattern = "0?(13|14|15|17|18|19)[0-9]{9}"; | ||
| 20 | String pattern = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$"; | ||
| 21 | Pattern r = Pattern.compile(pattern); | ||
| 22 | Matcher m = r.matcher(mobile); | ||
| 23 | return m.find(); | ||
| 24 | } | ||
| 25 | |||
| 26 | } |
| ... | @@ -2,6 +2,7 @@ package com.topdraw.test.business.process.rest; | ... | @@ -2,6 +2,7 @@ package com.topdraw.test.business.process.rest; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.topdraw.BaseTest; | 4 | import com.topdraw.BaseTest; |
| 5 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
| 5 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 6 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 6 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 7 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| 7 | import com.topdraw.business.process.domian.weixin.BindBean; | 8 | import com.topdraw.business.process.domian.weixin.BindBean; |
| ... | @@ -11,6 +12,7 @@ import com.topdraw.business.process.rest.UserOperationController; | ... | @@ -11,6 +12,7 @@ import com.topdraw.business.process.rest.UserOperationController; |
| 11 | import com.topdraw.common.ResultInfo; | 12 | import com.topdraw.common.ResultInfo; |
| 12 | import org.junit.Test; | 13 | import org.junit.Test; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.util.Base64Utils; | ||
| 14 | 16 | ||
| 15 | import java.sql.Timestamp; | 17 | import java.sql.Timestamp; |
| 16 | 18 | ||
| ... | @@ -151,6 +153,25 @@ public class UserOperationControllerTest extends BaseTest { | ... | @@ -151,6 +153,25 @@ public class UserOperationControllerTest extends BaseTest { |
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | @Test | 155 | @Test |
| 156 | public void appRegister() { | ||
| 157 | try { | ||
| 158 | UserApp userApp = new UserApp(); | ||
| 159 | userApp.setUsername("18271269120"); | ||
| 160 | // 类型 0:苹果;1:安卓;-1:未知 | ||
| 161 | userApp.setType(1); | ||
| 162 | |||
| 163 | |||
| 164 | userApp.setAccount("fdsfsdfsdfs"); | ||
| 165 | userApp.setAccountType(3); | ||
| 166 | |||
| 167 | ResultInfo weixinUserAndMember = this.userOperationController.appRegister(userApp); | ||
| 168 | System.out.println(weixinUserAndMember); | ||
| 169 | } catch (Exception e) { | ||
| 170 | e.printStackTrace(); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | @Test | ||
| 154 | public void createTvUserAndMember() { | 175 | public void createTvUserAndMember() { |
| 155 | try { | 176 | try { |
| 156 | String a = "{\n" + | 177 | String a = "{\n" + | ... | ... |
-
Please register or sign in to post a comment