1.app账号登录时兼容海南app账号历史数据
Showing
38 changed files
with
2145 additions
and
4 deletions
| ... | @@ -44,7 +44,7 @@ public class Member implements Serializable { | ... | @@ -44,7 +44,7 @@ public class Member implements Serializable { |
| 44 | @Column(name = "code") | 44 | @Column(name = "code") |
| 45 | private String code; | 45 | private String code; |
| 46 | 46 | ||
| 47 | /** 类型 1:大屏;2:小屏 */ | 47 | /** 类型 1:大屏;2:小屏 3:app;*/ |
| 48 | @Column(name = "`type`") | 48 | @Column(name = "`type`") |
| 49 | private Integer type; | 49 | private Integer type; |
| 50 | 50 | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/domain/UserAppIdManual.java
0 → 100644
| 1 | package com.topdraw.business.module.user.app.domain; | ||
| 2 | |||
| 3 | import cn.hutool.core.bean.BeanUtil; | ||
| 4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 5 | import lombok.Data; | ||
| 6 | import lombok.experimental.Accessors; | ||
| 7 | import org.springframework.data.annotation.CreatedDate; | ||
| 8 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 9 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 10 | |||
| 11 | import javax.persistence.*; | ||
| 12 | import java.io.Serializable; | ||
| 13 | import java.sql.Timestamp; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author XiangHan | ||
| 17 | * @date 2022-06-27 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="uc_user_app") | ||
| 24 | public class UserAppIdManual implements Serializable { | ||
| 25 | |||
| 26 | // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号 | ||
| 27 | @Transient | ||
| 28 | private Integer accountType; | ||
| 29 | |||
| 30 | // 第三方账号 | ||
| 31 | @Transient | ||
| 32 | private String account; | ||
| 33 | |||
| 34 | // ID | ||
| 35 | @Id | ||
| 36 | @GeneratedValue(strategy = GenerationType.SEQUENCE) | ||
| 37 | @Column(name = "id") | ||
| 38 | private Long id; | ||
| 39 | |||
| 40 | // 会员id | ||
| 41 | @Column(name = "member_id") | ||
| 42 | private Long memberId; | ||
| 43 | |||
| 44 | // 用户名(一般为手机号) | ||
| 45 | @Column(name = "username", nullable = false) | ||
| 46 | private String username; | ||
| 47 | |||
| 48 | // 密码 | ||
| 49 | @Column(name = "password") | ||
| 50 | private String password; | ||
| 51 | |||
| 52 | // 类型 0:苹果;1:安卓;-1:未知 | ||
| 53 | @Column(name = "type", nullable = false) | ||
| 54 | private Integer type; | ||
| 55 | |||
| 56 | // 状态 0:禁用;1:生效;-1:注销 | ||
| 57 | @Column(name = "status", nullable = false) | ||
| 58 | private Integer status; | ||
| 59 | |||
| 60 | // 昵称 | ||
| 61 | @Column(name = "nickname") | ||
| 62 | private String nickname; | ||
| 63 | |||
| 64 | // 头像地址 | ||
| 65 | @Column(name = "headimgurl") | ||
| 66 | private String headimgurl; | ||
| 67 | |||
| 68 | // 邮箱 | ||
| 69 | @Column(name = "email") | ||
| 70 | private String email; | ||
| 71 | |||
| 72 | // 手机号 | ||
| 73 | @Column(name = "cellphone") | ||
| 74 | private String cellphone; | ||
| 75 | |||
| 76 | // 性别 0:女;1:男;-1:其他 | ||
| 77 | @Column(name = "gender") | ||
| 78 | private Integer gender; | ||
| 79 | |||
| 80 | // 生日 | ||
| 81 | @Column(name = "birthday") | ||
| 82 | private String birthday; | ||
| 83 | |||
| 84 | // 最近活跃时间 | ||
| 85 | @Column(name = "last_active_time") | ||
| 86 | private Timestamp lastActiveTime; | ||
| 87 | |||
| 88 | // 注销时间 | ||
| 89 | @Column(name = "delete_time") | ||
| 90 | private Timestamp deleteTime; | ||
| 91 | |||
| 92 | // 标签 | ||
| 93 | @Column(name = "tags") | ||
| 94 | private String tags; | ||
| 95 | |||
| 96 | // 描述 | ||
| 97 | @Column(name = "description") | ||
| 98 | private String description; | ||
| 99 | |||
| 100 | // 创建时间 | ||
| 101 | @CreatedDate | ||
| 102 | @Column(name = "create_time") | ||
| 103 | private Timestamp createTime; | ||
| 104 | |||
| 105 | // 更新时间 | ||
| 106 | @LastModifiedDate | ||
| 107 | @Column(name = "update_time") | ||
| 108 | private Timestamp updateTime; | ||
| 109 | |||
| 110 | public void copy(UserAppIdManual source){ | ||
| 111 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 112 | } | ||
| 113 | } |
| 1 | package com.topdraw.business.module.user.app.repository; | 1 | package com.topdraw.business.module.user.app.repository; |
| 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.UserAppIdManual; | ||
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | 5 | import org.springframework.data.jpa.repository.JpaRepository; |
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| 6 | import org.springframework.data.jpa.repository.Modifying; | 7 | import org.springframework.data.jpa.repository.Modifying; |
| ... | @@ -47,4 +48,12 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec | ... | @@ -47,4 +48,12 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec |
| 47 | @Query(value = "UPDATE `uc_user_app` SET `last_active_time` = now(), `nickname` = ?2, `headimgurl` = ?3 " + | 48 | @Query(value = "UPDATE `uc_user_app` SET `last_active_time` = now(), `nickname` = ?2, `headimgurl` = ?3 " + |
| 48 | " WHERE `username` = ?1 and `status` = 1 ", nativeQuery = true) | 49 | " WHERE `username` = ?1 and `status` = 1 ", nativeQuery = true) |
| 49 | Integer updateAppLastActiveTimeAndNicknameAndHeadImg(String username, String nickname, String headimgurl); | 50 | Integer updateAppLastActiveTimeAndNicknameAndHeadImg(String username, String nickname, String headimgurl); |
| 51 | |||
| 52 | @Modifying | ||
| 53 | @Query(value = "INSERT INTO `uc_user_app`(`id`, `member_id`, `username`, `password`, `type`, `status`, `nickname`, `headimgurl`, `email`, `cellphone`, `gender`, `birthday`, `last_active_time`, `delete_time`, `tags`, `description`, `create_time`, `update_time`) " + | ||
| 54 | " VALUES (:#{#resources.id}, :#{#resources.memberId}, :#{#resources.username}, :#{#resources.password}, :#{#resources.type}," + | ||
| 55 | " 1, :#{#resources.nickname}, :#{#resources.headimgurl}, :#{#resources.email}, :#{#resources.cellphone}, " + | ||
| 56 | " :#{#resources.gender}, NULL, now(), NULL, :#{#resources.tags}, " + | ||
| 57 | " :#{#resources.description}, :#{#resources.createTime}, now());", nativeQuery = true) | ||
| 58 | void saveByIdManual(@Param("resources") UserAppIdManual userAppIdManual); | ||
| 50 | } | 59 | } | ... | ... |
| ... | @@ -6,11 +6,12 @@ import com.topdraw.business.module.user.app.domain.UserAppBind; | ... | @@ -6,11 +6,12 @@ import com.topdraw.business.module.user.app.domain.UserAppBind; |
| 6 | import com.topdraw.business.module.user.app.service.UserAppBindService; | 6 | import com.topdraw.business.module.user.app.service.UserAppBindService; |
| 7 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | 7 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; |
| 8 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; | 8 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; |
| 9 | import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; | 9 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; |
| 10 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 11 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 10 | import com.topdraw.common.ResultInfo; | 12 | import com.topdraw.common.ResultInfo; |
| 11 | import com.topdraw.annotation.Log; | 13 | import com.topdraw.annotation.Log; |
| 12 | import com.topdraw.business.module.user.app.service.UserAppService; | 14 | import com.topdraw.business.module.user.app.service.UserAppService; |
| 13 | import com.topdraw.util.RegexUtil; | ||
| 14 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.apache.commons.lang3.StringUtils; | 16 | import org.apache.commons.lang3.StringUtils; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -36,6 +37,61 @@ public class UserAppController { | ... | @@ -36,6 +37,61 @@ public class UserAppController { |
| 36 | private UserAppBindService userAppBindService; | 37 | private UserAppBindService userAppBindService; |
| 37 | 38 | ||
| 38 | @Log | 39 | @Log |
| 40 | @PostMapping(value = "/saveAppAndBindWeibo4Vis") | ||
| 41 | @ApiOperation("兼容海南app原微博数据") | ||
| 42 | @AnonymousAccess | ||
| 43 | public ResultInfo saveAppAndBindWeibo4Vis(@Validated @RequestBody VisUserWeibo resources) { | ||
| 44 | log.info("兼容海南app原weibo数据,参数 ==>> [saveAppAndBindWeibo4Vis#{}]", resources); | ||
| 45 | String userId = resources.getUserId(); | ||
| 46 | |||
| 47 | if (StringUtils.isBlank(userId)) { | ||
| 48 | log.error("兼容海南app原weibo数据,参数错误,app账号不得为空,[saveAppAndBindWeibo4Vis#{}]", resources); | ||
| 49 | return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空"); | ||
| 50 | } | ||
| 51 | |||
| 52 | return this.userAppService.saveAppAndBindWeibo4Vis(resources); | ||
| 53 | } | ||
| 54 | |||
| 55 | @Log | ||
| 56 | @PostMapping(value = "/saveAppAndBindQq4Vis") | ||
| 57 | @ApiOperation("兼容海南app原QQ数据") | ||
| 58 | @AnonymousAccess | ||
| 59 | public ResultInfo saveAppAndBindQq4Vis(@Validated @RequestBody VisUserQq resources) { | ||
| 60 | log.info("兼容海南app原QQ数据,参数 ==>> [saveAppAndBindQq4Vis#{}]", resources); | ||
| 61 | String openid = resources.getOpenid(); | ||
| 62 | if (StringUtils.isBlank(openid)) { | ||
| 63 | log.error("兼容海南app原QQ数据,参数错误,app账号不得为空,[saveAppAndBindWeibo4Vis#{}]", resources); | ||
| 64 | return ResultInfo.failure("修改app账号密码失败,参数错误,无openid"); | ||
| 65 | } | ||
| 66 | |||
| 67 | return this.userAppService.saveAppAndBindQq4Vis(resources); | ||
| 68 | |||
| 69 | } | ||
| 70 | |||
| 71 | @Log | ||
| 72 | @PostMapping(value = "/saveAppAndBindWeixin4Vis") | ||
| 73 | @ApiOperation("兼容海南app原微信数据") | ||
| 74 | @AnonymousAccess | ||
| 75 | public ResultInfo saveAppAndBindWeixin4Vis(@Validated @RequestBody VisUserWeixin resources) { | ||
| 76 | log.info("兼容海南app原weibo数据,参数 ==>> [saveAppAndBindWeixin4Vis#{}]", resources); | ||
| 77 | String openid = resources.getOpenid(); | ||
| 78 | if (StringUtils.isBlank(openid)) { | ||
| 79 | log.error("兼容海南app原微信数据,参数错误,app账号不得为空,[saveAppAndBindWeixin4Vis#{}]", resources); | ||
| 80 | return ResultInfo.failure("兼容海南app原微信数据失败,参数错误,无openid"); | ||
| 81 | } | ||
| 82 | |||
| 83 | String username = resources.getUsername(); | ||
| 84 | if (StringUtils.isBlank(username)) { | ||
| 85 | log.error("兼容海南app原微信数据,参数错误,app账号不得为空,[saveAppAndBindWeixin4Vis#{}]", resources); | ||
| 86 | return ResultInfo.failure("兼容海南app原微信数据失败,参数错误,无username"); | ||
| 87 | } | ||
| 88 | |||
| 89 | return this.userAppService.saveAppAndBindWeixin4Vis(resources); | ||
| 90 | |||
| 91 | } | ||
| 92 | |||
| 93 | |||
| 94 | @Log | ||
| 39 | @PostMapping(value = "/updateAppLastActiveTimeAndNicknameAndHeadImg") | 95 | @PostMapping(value = "/updateAppLastActiveTimeAndNicknameAndHeadImg") |
| 40 | @ApiOperation("修改app账号最后登录时间、昵称和头像") | 96 | @ApiOperation("修改app账号最后登录时间、昵称和头像") |
| 41 | @AnonymousAccess | 97 | @AnonymousAccess | ... | ... |
| ... | @@ -4,6 +4,10 @@ import com.topdraw.business.module.user.app.domain.UserApp; | ... | @@ -4,6 +4,10 @@ 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.domain.UserAppBind; |
| 5 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; | 5 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; |
| 6 | import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; | 6 | import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; |
| 7 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; | ||
| 8 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 9 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 10 | import com.topdraw.common.ResultInfo; | ||
| 7 | 11 | ||
| 8 | /** | 12 | /** |
| 9 | * @author XiangHan | 13 | * @author XiangHan |
| ... | @@ -77,4 +81,10 @@ public interface UserAppService { | ... | @@ -77,4 +81,10 @@ public interface UserAppService { |
| 77 | 81 | ||
| 78 | 82 | ||
| 79 | boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources); | 83 | boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources); |
| 84 | |||
| 85 | ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources); | ||
| 86 | |||
| 87 | ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources); | ||
| 88 | |||
| 89 | ResultInfo saveAppAndBindQq4Vis(VisUserQq resources); | ||
| 80 | } | 90 | } | ... | ... |
| 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; | ||
| 3 | import com.topdraw.business.module.member.service.MemberService; | 6 | import com.topdraw.business.module.member.service.MemberService; |
| 4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 7 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 5 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | 8 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; |
| 6 | import com.topdraw.business.module.user.app.domain.UserApp; | 9 | import com.topdraw.business.module.user.app.domain.UserApp; |
| 7 | import com.topdraw.business.module.user.app.domain.UserAppBind; | 10 | import com.topdraw.business.module.user.app.domain.UserAppBind; |
| 11 | import com.topdraw.business.module.user.app.domain.UserAppIdManual; | ||
| 8 | import com.topdraw.business.module.user.app.domain.UserAppSimple; | 12 | import com.topdraw.business.module.user.app.domain.UserAppSimple; |
| 9 | import com.topdraw.business.module.user.app.repository.UserAppSimpleRepository; | 13 | import com.topdraw.business.module.user.app.repository.UserAppSimpleRepository; |
| 14 | import com.topdraw.business.module.user.app.service.UserAppBindService; | ||
| 15 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | ||
| 10 | import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; | 16 | import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; |
| 17 | import com.topdraw.business.module.vis.hainan.app.service.VisUserService; | ||
| 18 | import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO; | ||
| 19 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; | ||
| 20 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 21 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 22 | import com.topdraw.business.module.vis.hainan.weixin.repository.VisUserWeixinRepository; | ||
| 23 | import com.topdraw.common.ResultInfo; | ||
| 24 | import com.topdraw.util.TimestampUtil; | ||
| 25 | import com.topdraw.utils.StringUtils; | ||
| 11 | import com.topdraw.utils.ValidationUtil; | 26 | import com.topdraw.utils.ValidationUtil; |
| 12 | import com.topdraw.business.module.user.app.repository.UserAppRepository; | 27 | import com.topdraw.business.module.user.app.repository.UserAppRepository; |
| 13 | import com.topdraw.business.module.user.app.service.UserAppService; | 28 | import com.topdraw.business.module.user.app.service.UserAppService; |
| ... | @@ -22,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -22,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 22 | import org.springframework.dao.EmptyResultDataAccessException; | 37 | import org.springframework.dao.EmptyResultDataAccessException; |
| 23 | import org.springframework.util.Assert; | 38 | import org.springframework.util.Assert; |
| 24 | 39 | ||
| 40 | import java.sql.Timestamp; | ||
| 25 | import java.util.Objects; | 41 | import java.util.Objects; |
| 26 | 42 | ||
| 27 | /** | 43 | /** |
| ... | @@ -41,6 +57,10 @@ public class UserAppServiceImpl implements UserAppService { | ... | @@ -41,6 +57,10 @@ public class UserAppServiceImpl implements UserAppService { |
| 41 | private UserAppMapper userAppMapper; | 57 | private UserAppMapper userAppMapper; |
| 42 | @Autowired | 58 | @Autowired |
| 43 | private MemberService memberService; | 59 | private MemberService memberService; |
| 60 | @Autowired | ||
| 61 | private VisUserService visUserService; | ||
| 62 | @Autowired | ||
| 63 | private UserAppBindService userAppBindService; | ||
| 44 | 64 | ||
| 45 | 65 | ||
| 46 | @Override | 66 | @Override |
| ... | @@ -145,6 +165,257 @@ public class UserAppServiceImpl implements UserAppService { | ... | @@ -145,6 +165,257 @@ public class UserAppServiceImpl implements UserAppService { |
| 145 | } | 165 | } |
| 146 | 166 | ||
| 147 | @Override | 167 | @Override |
| 168 | public ResultInfo saveAppAndBindWeibo4Vis(VisUserWeibo resources) { | ||
| 169 | |||
| 170 | String username1 = resources.getUsername(); | ||
| 171 | UserAppDTO userAppDTO = this.findByUsername(username1); | ||
| 172 | if (Objects.nonNull(userAppDTO.getId()) && StringUtils.isNotBlank(userAppDTO.getHeadimgurl())) { | ||
| 173 | |||
| 174 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getUserId(), 5); | ||
| 175 | if (Objects.nonNull(userAppBindDTO.getId())) { | ||
| 176 | |||
| 177 | UserAppBind userAppBind = new UserAppBind(); | ||
| 178 | userAppBind.setAccount(resources.getUserId()); | ||
| 179 | userAppBind.setAccountType(3); | ||
| 180 | userAppBind.setUserAppId(userAppDTO.getId()); | ||
| 181 | userAppBind.setStatus(1); | ||
| 182 | userAppBind.setNickname(resources.getNickname()); | ||
| 183 | userAppBind.setHeadimgurl(resources.getIcon()); | ||
| 184 | this.userAppBindService.create(userAppBind); | ||
| 185 | } | ||
| 186 | |||
| 187 | return ResultInfo.success(userAppDTO); | ||
| 188 | } | ||
| 189 | |||
| 190 | Long visUserId = resources.getVisUserId(); | ||
| 191 | VisUserDTO visUserDTO = this.visUserService.findById(visUserId); | ||
| 192 | if (Objects.nonNull(visUserDTO.getId())) { | ||
| 193 | |||
| 194 | UserAppIdManual userAppIdManual = new UserAppIdManual(); | ||
| 195 | |||
| 196 | Long id = visUserDTO.getId(); | ||
| 197 | userAppIdManual.setId(id); | ||
| 198 | |||
| 199 | String username = visUserDTO.getUsername(); | ||
| 200 | userAppIdManual.setUsername(StringUtils.isBlank(username) ? resources.getUsername() : username); | ||
| 201 | |||
| 202 | String cellphone = visUserDTO.getCellphone(); | ||
| 203 | userAppIdManual.setCellphone(StringUtils.isBlank(cellphone) ? resources.getUsername() : cellphone); | ||
| 204 | |||
| 205 | String nickname = visUserDTO.getNickname(); | ||
| 206 | userAppIdManual.setNickname(StringUtils.isBlank(nickname) ? resources.getNickname() : nickname); | ||
| 207 | |||
| 208 | Integer gender = visUserDTO.getGender(); | ||
| 209 | userAppIdManual.setGender(Objects.isNull(gender) ? -1 : gender); | ||
| 210 | |||
| 211 | userAppIdManual.setHeadimgurl(resources.getIcon()); | ||
| 212 | |||
| 213 | String email = visUserDTO.getEmail(); | ||
| 214 | userAppIdManual.setEmail(StringUtils.isBlank(email) ? null : email); | ||
| 215 | |||
| 216 | String tags = visUserDTO.getTags(); | ||
| 217 | userAppIdManual.setTags(StringUtils.isBlank(tags) ? null : tags); | ||
| 218 | |||
| 219 | Timestamp createTime = visUserDTO.getCreateTime(); | ||
| 220 | userAppIdManual.setCreateTime(Objects.isNull(createTime) ? TimestampUtil.now() : createTime); | ||
| 221 | |||
| 222 | Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0); | ||
| 223 | MemberDTO memberDTO = this.memberService.create(member); | ||
| 224 | userAppIdManual.setMemberId(memberDTO.getId()); | ||
| 225 | |||
| 226 | userAppIdManual.setType(resources.getType()); | ||
| 227 | |||
| 228 | this.userAppRepository.saveByIdManual(userAppIdManual); | ||
| 229 | |||
| 230 | |||
| 231 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getUserId(), 5); | ||
| 232 | if (Objects.isNull(userAppBindDTO.getId())) { | ||
| 233 | |||
| 234 | UserAppBind userAppBind = new UserAppBind(); | ||
| 235 | userAppBind.setAccount(resources.getUserId()); | ||
| 236 | userAppBind.setAccountType(5); | ||
| 237 | userAppBind.setUserAppId(visUserId); | ||
| 238 | userAppBind.setStatus(1); | ||
| 239 | userAppBind.setNickname(resources.getNickname()); | ||
| 240 | userAppBind.setHeadimgurl(resources.getIcon()); | ||
| 241 | this.userAppBindService.create(userAppBind); | ||
| 242 | } | ||
| 243 | |||
| 244 | |||
| 245 | return ResultInfo.success(userAppIdManual); | ||
| 246 | } | ||
| 247 | |||
| 248 | return ResultInfo.failure(null); | ||
| 249 | } | ||
| 250 | |||
| 251 | @Override | ||
| 252 | @Transactional | ||
| 253 | public ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources) { | ||
| 254 | String username1 = resources.getUsername(); | ||
| 255 | UserAppDTO userAppDTO = this.findByUsername(username1); | ||
| 256 | if (Objects.nonNull(userAppDTO.getId()) && StringUtils.isNotBlank(userAppDTO.getHeadimgurl())) { | ||
| 257 | |||
| 258 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getOpenid(), 3); | ||
| 259 | if (Objects.nonNull(userAppBindDTO.getId())) { | ||
| 260 | |||
| 261 | UserAppBind userAppBind = new UserAppBind(); | ||
| 262 | userAppBind.setAccount(resources.getOpenid()); | ||
| 263 | userAppBind.setAccountType(3); | ||
| 264 | userAppBind.setUserAppId(userAppDTO.getId()); | ||
| 265 | userAppBind.setStatus(1); | ||
| 266 | userAppBind.setNickname(resources.getNickname()); | ||
| 267 | userAppBind.setHeadimgurl(resources.getHeadimgurl()); | ||
| 268 | this.userAppBindService.create(userAppBind); | ||
| 269 | } | ||
| 270 | |||
| 271 | return ResultInfo.success(userAppDTO); | ||
| 272 | } | ||
| 273 | |||
| 274 | Long visUserId = resources.getVisUserId(); | ||
| 275 | VisUserDTO visUserDTO = this.visUserService.findById(visUserId); | ||
| 276 | if (Objects.nonNull(visUserDTO.getId())) { | ||
| 277 | |||
| 278 | UserAppIdManual userAppIdManual = new UserAppIdManual(); | ||
| 279 | |||
| 280 | Long id = visUserDTO.getId(); | ||
| 281 | userAppIdManual.setId(id); | ||
| 282 | |||
| 283 | String username = visUserDTO.getUsername(); | ||
| 284 | userAppIdManual.setUsername(StringUtils.isBlank(username) ? resources.getUsername() : username); | ||
| 285 | |||
| 286 | String cellphone = visUserDTO.getCellphone(); | ||
| 287 | userAppIdManual.setCellphone(StringUtils.isBlank(cellphone) ? resources.getUsername() : cellphone); | ||
| 288 | |||
| 289 | String nickname = visUserDTO.getNickname(); | ||
| 290 | userAppIdManual.setNickname(StringUtils.isBlank(nickname) ? resources.getNickname() : nickname); | ||
| 291 | |||
| 292 | Integer gender = visUserDTO.getGender(); | ||
| 293 | userAppIdManual.setGender(Objects.isNull(gender) ? -1 : gender); | ||
| 294 | |||
| 295 | userAppIdManual.setHeadimgurl(resources.getHeadimgurl()); | ||
| 296 | |||
| 297 | String email = visUserDTO.getEmail(); | ||
| 298 | userAppIdManual.setEmail(StringUtils.isBlank(email) ? null : email); | ||
| 299 | |||
| 300 | String tags = visUserDTO.getTags(); | ||
| 301 | userAppIdManual.setTags(StringUtils.isBlank(tags) ? null : tags); | ||
| 302 | |||
| 303 | Timestamp createTime = visUserDTO.getCreateTime(); | ||
| 304 | userAppIdManual.setCreateTime(Objects.isNull(createTime) ? TimestampUtil.now() : createTime); | ||
| 305 | |||
| 306 | Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getHeadimgurl(), userAppIdManual.getNickname(), 0); | ||
| 307 | MemberDTO memberDTO = this.memberService.create(member); | ||
| 308 | userAppIdManual.setMemberId(memberDTO.getId()); | ||
| 309 | |||
| 310 | userAppIdManual.setType(resources.getType()); | ||
| 311 | |||
| 312 | this.userAppRepository.saveByIdManual(userAppIdManual); | ||
| 313 | |||
| 314 | |||
| 315 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getOpenid(), 3); | ||
| 316 | if (Objects.isNull(userAppBindDTO.getId())) { | ||
| 317 | |||
| 318 | UserAppBind userAppBind = new UserAppBind(); | ||
| 319 | userAppBind.setAccount(resources.getOpenid()); | ||
| 320 | userAppBind.setAccountType(3); | ||
| 321 | userAppBind.setUserAppId(visUserId); | ||
| 322 | userAppBind.setStatus(1); | ||
| 323 | userAppBind.setNickname(resources.getNickname()); | ||
| 324 | userAppBind.setHeadimgurl(resources.getHeadimgurl()); | ||
| 325 | this.userAppBindService.create(userAppBind); | ||
| 326 | } | ||
| 327 | |||
| 328 | |||
| 329 | return ResultInfo.success(userAppIdManual); | ||
| 330 | } | ||
| 331 | |||
| 332 | return ResultInfo.failure(null); | ||
| 333 | } | ||
| 334 | |||
| 335 | @Override | ||
| 336 | public ResultInfo saveAppAndBindQq4Vis(VisUserQq resources) { | ||
| 337 | String username1 = resources.getUsername(); | ||
| 338 | UserAppDTO userAppDTO = this.findByUsername(username1); | ||
| 339 | if (Objects.nonNull(userAppDTO.getId()) && StringUtils.isNotBlank(userAppDTO.getHeadimgurl())) { | ||
| 340 | |||
| 341 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getOpenid(), 4); | ||
| 342 | if (Objects.nonNull(userAppBindDTO.getId())) { | ||
| 343 | |||
| 344 | UserAppBind userAppBind = new UserAppBind(); | ||
| 345 | userAppBind.setAccount(resources.getOpenid()); | ||
| 346 | userAppBind.setAccountType(4); | ||
| 347 | userAppBind.setUserAppId(userAppDTO.getId()); | ||
| 348 | userAppBind.setStatus(1); | ||
| 349 | userAppBind.setNickname(resources.getNickname()); | ||
| 350 | userAppBind.setHeadimgurl(resources.getIcon()); | ||
| 351 | this.userAppBindService.create(userAppBind); | ||
| 352 | } | ||
| 353 | |||
| 354 | return ResultInfo.success(userAppDTO); | ||
| 355 | } | ||
| 356 | |||
| 357 | Long visUserId = resources.getVisUserId(); | ||
| 358 | VisUserDTO visUserDTO = this.visUserService.findById(visUserId); | ||
| 359 | if (Objects.nonNull(visUserDTO.getId())) { | ||
| 360 | |||
| 361 | UserAppIdManual userAppIdManual = new UserAppIdManual(); | ||
| 362 | |||
| 363 | Long id = visUserDTO.getId(); | ||
| 364 | userAppIdManual.setId(id); | ||
| 365 | |||
| 366 | String username = visUserDTO.getUsername(); | ||
| 367 | userAppIdManual.setUsername(StringUtils.isBlank(username) ? resources.getUsername() : username); | ||
| 368 | |||
| 369 | String cellphone = visUserDTO.getCellphone(); | ||
| 370 | userAppIdManual.setCellphone(StringUtils.isBlank(cellphone) ? resources.getUsername() : cellphone); | ||
| 371 | |||
| 372 | String nickname = visUserDTO.getNickname(); | ||
| 373 | userAppIdManual.setNickname(StringUtils.isBlank(nickname) ? resources.getNickname() : nickname); | ||
| 374 | |||
| 375 | Integer gender = visUserDTO.getGender(); | ||
| 376 | userAppIdManual.setGender(Objects.isNull(gender) ? -1 : gender); | ||
| 377 | |||
| 378 | userAppIdManual.setHeadimgurl(resources.getIcon()); | ||
| 379 | |||
| 380 | String email = visUserDTO.getEmail(); | ||
| 381 | userAppIdManual.setEmail(StringUtils.isBlank(email) ? null : email); | ||
| 382 | |||
| 383 | String tags = visUserDTO.getTags(); | ||
| 384 | userAppIdManual.setTags(StringUtils.isBlank(tags) ? null : tags); | ||
| 385 | |||
| 386 | Timestamp createTime = visUserDTO.getCreateTime(); | ||
| 387 | userAppIdManual.setCreateTime(Objects.isNull(createTime) ? TimestampUtil.now() : createTime); | ||
| 388 | |||
| 389 | Member member = MemberBuilder.build(MemberTypeConstant.app, resources.getIcon(), userAppIdManual.getNickname(), 0); | ||
| 390 | MemberDTO memberDTO = this.memberService.create(member); | ||
| 391 | userAppIdManual.setMemberId(memberDTO.getId()); | ||
| 392 | |||
| 393 | userAppIdManual.setType(resources.getType()); | ||
| 394 | |||
| 395 | this.userAppRepository.saveByIdManual(userAppIdManual); | ||
| 396 | |||
| 397 | |||
| 398 | UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(resources.getOpenid(), 4); | ||
| 399 | if (Objects.isNull(userAppBindDTO.getId())) { | ||
| 400 | |||
| 401 | UserAppBind userAppBind = new UserAppBind(); | ||
| 402 | userAppBind.setAccount(resources.getOpenid()); | ||
| 403 | userAppBind.setAccountType(4); | ||
| 404 | userAppBind.setUserAppId(visUserId); | ||
| 405 | userAppBind.setStatus(1); | ||
| 406 | userAppBind.setNickname(resources.getNickname()); | ||
| 407 | userAppBind.setHeadimgurl(resources.getIcon()); | ||
| 408 | this.userAppBindService.create(userAppBind); | ||
| 409 | } | ||
| 410 | |||
| 411 | |||
| 412 | return ResultInfo.success(userAppIdManual); | ||
| 413 | } | ||
| 414 | |||
| 415 | return ResultInfo.failure(null); | ||
| 416 | } | ||
| 417 | |||
| 418 | @Override | ||
| 148 | @Transactional(rollbackFor = Exception.class) | 419 | @Transactional(rollbackFor = Exception.class) |
| 149 | public boolean updatePasswordById(UserApp resources) { | 420 | public boolean updatePasswordById(UserApp resources) { |
| 150 | return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0; | 421 | return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0; | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/module/vis/hainan/app/domain/VisUser.java
0 → 100644
| 1 | package com.topdraw.business.module.vis.hainan.app.domain; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import lombok.experimental.Accessors; | ||
| 5 | import cn.hutool.core.bean.BeanUtil; | ||
| 6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 7 | import javax.persistence.*; | ||
| 8 | import org.springframework.data.annotation.CreatedDate; | ||
| 9 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 11 | import java.sql.Timestamp; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author XiangHan | ||
| 17 | * @date 2022-07-14 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="vis_user") | ||
| 24 | public class VisUser implements Serializable { | ||
| 25 | |||
| 26 | // ID | ||
| 27 | @Id | ||
| 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 29 | @Column(name = "id") | ||
| 30 | private Long id; | ||
| 31 | |||
| 32 | // 所有者ID | ||
| 33 | @Column(name = "person_id") | ||
| 34 | private Long personId; | ||
| 35 | |||
| 36 | // 平台 | ||
| 37 | @Column(name = "platform") | ||
| 38 | private String platform; | ||
| 39 | |||
| 40 | // 平台账号 | ||
| 41 | @Column(name = "platform_account") | ||
| 42 | private String platformAccount; | ||
| 43 | |||
| 44 | // 用户名 | ||
| 45 | @Column(name = "username") | ||
| 46 | private String username; | ||
| 47 | |||
| 48 | // 密码 | ||
| 49 | @Column(name = "password") | ||
| 50 | private String password; | ||
| 51 | |||
| 52 | // 积分 | ||
| 53 | @Column(name = "points") | ||
| 54 | private Integer points; | ||
| 55 | |||
| 56 | // 昵称 | ||
| 57 | @Column(name = "nickname") | ||
| 58 | private String nickname; | ||
| 59 | |||
| 60 | // 真实姓名 | ||
| 61 | @Column(name = "realname") | ||
| 62 | private String realname; | ||
| 63 | |||
| 64 | // 头像 | ||
| 65 | @Column(name = "image") | ||
| 66 | private String image; | ||
| 67 | |||
| 68 | // 电子邮件 | ||
| 69 | @Column(name = "email") | ||
| 70 | private String email; | ||
| 71 | |||
| 72 | // 手机号 | ||
| 73 | @Column(name = "cellphone") | ||
| 74 | private String cellphone; | ||
| 75 | |||
| 76 | // 0-女 1-男 2-其他 | ||
| 77 | @Column(name = "gender") | ||
| 78 | private Integer gender; | ||
| 79 | |||
| 80 | // 生日 | ||
| 81 | @Column(name = "birthday") | ||
| 82 | private Integer birthday; | ||
| 83 | |||
| 84 | // 登录天数(总天数) | ||
| 85 | @Column(name = "login_days") | ||
| 86 | private Integer loginDays; | ||
| 87 | |||
| 88 | // 连续天数 | ||
| 89 | @Column(name = "continue_days") | ||
| 90 | private Integer continueDays; | ||
| 91 | |||
| 92 | // 活跃时间 | ||
| 93 | @Column(name = "active_time") | ||
| 94 | private Timestamp activeTime; | ||
| 95 | |||
| 96 | // 标签 | ||
| 97 | @Column(name = "tags") | ||
| 98 | private String tags; | ||
| 99 | |||
| 100 | // 登录类型:1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 | ||
| 101 | @Column(name = "login_type") | ||
| 102 | private Integer loginType; | ||
| 103 | |||
| 104 | // 用户绑定ID | ||
| 105 | @Column(name = "vis_user_id") | ||
| 106 | private Long visUserId; | ||
| 107 | |||
| 108 | // 微信绑定ID | ||
| 109 | @Column(name = "vis_user_weixin_id") | ||
| 110 | private Long visUserWeixinId; | ||
| 111 | |||
| 112 | // QQ绑定ID | ||
| 113 | @Column(name = "vis_user_qq_id") | ||
| 114 | private Long visUserQqId; | ||
| 115 | |||
| 116 | // 微博绑定ID | ||
| 117 | @Column(name = "vis_user_weibo_id") | ||
| 118 | private Long visUserWeiboId; | ||
| 119 | |||
| 120 | // 苹果绑定ID | ||
| 121 | @Column(name = "vis_user_apple_id") | ||
| 122 | private Long visUserAppleId; | ||
| 123 | |||
| 124 | // 状态:默认1-生效 2-失效 | ||
| 125 | @Column(name = "status") | ||
| 126 | private Integer status; | ||
| 127 | |||
| 128 | // 创建时间 | ||
| 129 | @CreatedDate | ||
| 130 | @Column(name = "create_time") | ||
| 131 | private Timestamp createTime; | ||
| 132 | |||
| 133 | // 更新时间 | ||
| 134 | @LastModifiedDate | ||
| 135 | @Column(name = "update_time") | ||
| 136 | private Timestamp updateTime; | ||
| 137 | |||
| 138 | public void copy(VisUser source){ | ||
| 139 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 140 | } | ||
| 141 | } |
| 1 | package com.topdraw.business.module.vis.hainan.app.repository; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.vis.hainan.app.domain.VisUser; | ||
| 5 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * @author XiangHan | ||
| 10 | * @date 2022-07-14 | ||
| 11 | */ | ||
| 12 | public interface VisUserRepository extends JpaRepository<VisUser, Long>, JpaSpecificationExecutor<VisUser> { | ||
| 13 | |||
| 14 | } |
| 1 | package com.topdraw.business.module.vis.hainan.app.service; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.app.domain.VisUser; | ||
| 4 | import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * @author XiangHan | ||
| 8 | * @date 2022-07-14 | ||
| 9 | */ | ||
| 10 | public interface VisUserService { | ||
| 11 | |||
| 12 | /** | ||
| 13 | * 根据ID查询 | ||
| 14 | * @param id ID | ||
| 15 | * @return UserDTO | ||
| 16 | */ | ||
| 17 | VisUserDTO findById(Long id); | ||
| 18 | |||
| 19 | void create(VisUser resources); | ||
| 20 | |||
| 21 | void update(VisUser resources); | ||
| 22 | |||
| 23 | void delete(Long id); | ||
| 24 | |||
| 25 | } |
| 1 | package com.topdraw.business.module.vis.hainan.app.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import java.sql.Timestamp; | ||
| 5 | import java.io.Serializable; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author XiangHan | ||
| 10 | * @date 2022-07-14 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class VisUserDTO implements Serializable { | ||
| 14 | |||
| 15 | // ID | ||
| 16 | private Long id; | ||
| 17 | |||
| 18 | // 所有者ID | ||
| 19 | private Long personId; | ||
| 20 | |||
| 21 | // 平台 | ||
| 22 | private String platform; | ||
| 23 | |||
| 24 | // 平台账号 | ||
| 25 | private String platformAccount; | ||
| 26 | |||
| 27 | // 用户名 | ||
| 28 | private String username; | ||
| 29 | |||
| 30 | // 密码 | ||
| 31 | private String password; | ||
| 32 | |||
| 33 | // 积分 | ||
| 34 | private Integer points; | ||
| 35 | |||
| 36 | // 昵称 | ||
| 37 | private String nickname; | ||
| 38 | |||
| 39 | // 真实姓名 | ||
| 40 | private String realname; | ||
| 41 | |||
| 42 | // 头像 | ||
| 43 | private String image; | ||
| 44 | |||
| 45 | // 电子邮件 | ||
| 46 | private String email; | ||
| 47 | |||
| 48 | // 手机号 | ||
| 49 | private String cellphone; | ||
| 50 | |||
| 51 | // 0-女 1-男 2-其他 | ||
| 52 | private Integer gender; | ||
| 53 | |||
| 54 | // 生日 | ||
| 55 | private Integer birthday; | ||
| 56 | |||
| 57 | // 登录天数(总天数) | ||
| 58 | private Integer loginDays; | ||
| 59 | |||
| 60 | // 连续天数 | ||
| 61 | private Integer continueDays; | ||
| 62 | |||
| 63 | // 活跃时间 | ||
| 64 | private Timestamp activeTime; | ||
| 65 | |||
| 66 | // 标签 | ||
| 67 | private String tags; | ||
| 68 | |||
| 69 | // 登录类型:1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 | ||
| 70 | private Integer loginType; | ||
| 71 | |||
| 72 | // 用户绑定ID | ||
| 73 | private Long visUserId; | ||
| 74 | |||
| 75 | // 微信绑定ID | ||
| 76 | private Long visUserWeixinId; | ||
| 77 | |||
| 78 | // QQ绑定ID | ||
| 79 | private Long visUserQqId; | ||
| 80 | |||
| 81 | // 微博绑定ID | ||
| 82 | private Long visUserWeiboId; | ||
| 83 | |||
| 84 | // 苹果绑定ID | ||
| 85 | private Long visUserAppleId; | ||
| 86 | |||
| 87 | // 状态:默认1-生效 2-失效 | ||
| 88 | private Integer status; | ||
| 89 | |||
| 90 | // 创建时间 | ||
| 91 | private Timestamp createTime; | ||
| 92 | |||
| 93 | // 更新时间 | ||
| 94 | private Timestamp updateTime; | ||
| 95 | } |
| 1 | package com.topdraw.business.module.vis.hainan.app.service.impl; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.app.domain.VisUser; | ||
| 4 | import com.topdraw.business.module.vis.hainan.app.repository.VisUserRepository; | ||
| 5 | import com.topdraw.business.module.vis.hainan.app.service.VisUserService; | ||
| 6 | import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO; | ||
| 7 | import com.topdraw.business.module.vis.hainan.app.service.mapper.VisUserMapper; | ||
| 8 | import com.topdraw.utils.ValidationUtil; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | import org.springframework.stereotype.Service; | ||
| 11 | import org.springframework.transaction.annotation.Propagation; | ||
| 12 | import org.springframework.transaction.annotation.Transactional; | ||
| 13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 14 | import org.springframework.util.Assert; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @author XiangHan | ||
| 18 | * @date 2022-07-14 | ||
| 19 | */ | ||
| 20 | @Service | ||
| 21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 22 | public class VisUserServiceImpl implements VisUserService { | ||
| 23 | |||
| 24 | @Autowired | ||
| 25 | private VisUserRepository visUserRepository; | ||
| 26 | |||
| 27 | @Autowired | ||
| 28 | private VisUserMapper visUserMapper; | ||
| 29 | |||
| 30 | @Override | ||
| 31 | public VisUserDTO findById(Long id) { | ||
| 32 | VisUser visUser = visUserRepository.findById(id).orElseGet(VisUser::new); | ||
| 33 | ValidationUtil.isNull(visUser.getId(),"User","id",id); | ||
| 34 | return visUserMapper.toDto(visUser); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | @Transactional(rollbackFor = Exception.class) | ||
| 39 | public void create(VisUser resources) { | ||
| 40 | visUserRepository.save(resources); | ||
| 41 | } | ||
| 42 | |||
| 43 | @Override | ||
| 44 | @Transactional(rollbackFor = Exception.class) | ||
| 45 | public void update(VisUser resources) { | ||
| 46 | VisUser User = visUserRepository.findById(resources.getId()).orElseGet(VisUser::new); | ||
| 47 | ValidationUtil.isNull( User.getId(),"User","id",resources.getId()); | ||
| 48 | User.copy(resources); | ||
| 49 | visUserRepository.save(User); | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | @Transactional(rollbackFor = Exception.class) | ||
| 54 | public void delete(Long id) { | ||
| 55 | Assert.notNull(id, "The given id must not be null!"); | ||
| 56 | VisUser User = visUserRepository.findById(id).orElseThrow( | ||
| 57 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUser.class, id), 1)); | ||
| 58 | visUserRepository.delete(User); | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | } |
| 1 | package com.topdraw.business.module.vis.hainan.app.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.vis.hainan.app.domain.VisUser; | ||
| 5 | import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author XiangHan | ||
| 11 | * @date 2022-07-14 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface VisUserMapper extends BaseMapper<VisUserDTO, VisUser> { | ||
| 15 | |||
| 16 | } |
| 1 | package com.topdraw.business.module.vis.hainan.apple.domain; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import lombok.experimental.Accessors; | ||
| 5 | import cn.hutool.core.bean.BeanUtil; | ||
| 6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 7 | import javax.persistence.*; | ||
| 8 | import org.springframework.data.annotation.CreatedDate; | ||
| 9 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 11 | import java.sql.Timestamp; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author XiangHan | ||
| 17 | * @date 2022-07-14 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="vis_user_apple") | ||
| 24 | public class VisUserApple implements Serializable { | ||
| 25 | |||
| 26 | // ID | ||
| 27 | @Id | ||
| 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 29 | @Column(name = "id") | ||
| 30 | private Long id; | ||
| 31 | |||
| 32 | // 所有者ID | ||
| 33 | @Column(name = "person_id") | ||
| 34 | private Long personId; | ||
| 35 | |||
| 36 | // 用户ID | ||
| 37 | @Column(name = "vis_user_id") | ||
| 38 | private Long visUserId; | ||
| 39 | |||
| 40 | // 苹果用户ID | ||
| 41 | @Column(name = "user") | ||
| 42 | private String user; | ||
| 43 | |||
| 44 | @Column(name = "identity_token") | ||
| 45 | private String identityToken; | ||
| 46 | |||
| 47 | @Column(name = "real_user_status") | ||
| 48 | private String realUserStatus; | ||
| 49 | |||
| 50 | @Column(name = "authorized_scopes") | ||
| 51 | private String authorizedScopes; | ||
| 52 | |||
| 53 | @Column(name = "authorization_code") | ||
| 54 | private String authorizationCode; | ||
| 55 | |||
| 56 | // 状态 0-失效 1-有效 | ||
| 57 | @Column(name = "status") | ||
| 58 | private Integer status; | ||
| 59 | |||
| 60 | // 全名 | ||
| 61 | @Column(name = "full_name") | ||
| 62 | private String fullName; | ||
| 63 | |||
| 64 | // E-main | ||
| 65 | @Column(name = "email") | ||
| 66 | private String email; | ||
| 67 | |||
| 68 | // 昵称 | ||
| 69 | @Column(name = "nickname") | ||
| 70 | private String nickname; | ||
| 71 | |||
| 72 | // 性别 | ||
| 73 | @Column(name = "sex") | ||
| 74 | private Integer sex; | ||
| 75 | |||
| 76 | // 国家 | ||
| 77 | @Column(name = "country") | ||
| 78 | private String country; | ||
| 79 | |||
| 80 | // 省份 | ||
| 81 | @Column(name = "province") | ||
| 82 | private String province; | ||
| 83 | |||
| 84 | // 城市 | ||
| 85 | @Column(name = "city") | ||
| 86 | private String city; | ||
| 87 | |||
| 88 | // 头像地址 | ||
| 89 | @Column(name = "icon") | ||
| 90 | private String icon; | ||
| 91 | |||
| 92 | // 描述 | ||
| 93 | @Column(name = "description") | ||
| 94 | private String description; | ||
| 95 | |||
| 96 | // 创建时间 | ||
| 97 | @CreatedDate | ||
| 98 | @Column(name = "create_time") | ||
| 99 | private Timestamp createTime; | ||
| 100 | |||
| 101 | // 更新时间 | ||
| 102 | @LastModifiedDate | ||
| 103 | @Column(name = "update_time") | ||
| 104 | private Timestamp updateTime; | ||
| 105 | |||
| 106 | public void copy(VisUserApple source){ | ||
| 107 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 108 | } | ||
| 109 | } |
| 1 | package com.topdraw.business.module.vis.hainan.apple.repository; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple; | ||
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserAppleRepository extends JpaRepository<VisUserApple, Long>, JpaSpecificationExecutor<VisUserApple> { | ||
| 12 | |||
| 13 | } |
| 1 | package com.topdraw.business.module.vis.hainan.apple.service; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple; | ||
| 5 | import com.topdraw.business.module.vis.hainan.apple.service.dto.VisUserAppleDTO; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserAppleService { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * 根据ID查询 | ||
| 15 | * @param id ID | ||
| 16 | * @return VisUserAppleDTO | ||
| 17 | */ | ||
| 18 | VisUserAppleDTO findById(Long id); | ||
| 19 | |||
| 20 | void create(VisUserApple resources); | ||
| 21 | |||
| 22 | void update(VisUserApple resources); | ||
| 23 | |||
| 24 | void delete(Long id); | ||
| 25 | |||
| 26 | } |
| 1 | package com.topdraw.business.module.vis.hainan.apple.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import java.sql.Timestamp; | ||
| 5 | import java.io.Serializable; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author XiangHan | ||
| 10 | * @date 2022-07-14 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class VisUserAppleDTO implements Serializable { | ||
| 14 | |||
| 15 | // ID | ||
| 16 | private Long id; | ||
| 17 | |||
| 18 | // 所有者ID | ||
| 19 | private Long personId; | ||
| 20 | |||
| 21 | // 用户ID | ||
| 22 | private Long visUserId; | ||
| 23 | |||
| 24 | // 苹果用户ID | ||
| 25 | private String user; | ||
| 26 | |||
| 27 | private String identityToken; | ||
| 28 | |||
| 29 | private String realUserStatus; | ||
| 30 | |||
| 31 | private String authorizedScopes; | ||
| 32 | |||
| 33 | private String authorizationCode; | ||
| 34 | |||
| 35 | // 状态 0-失效 1-有效 | ||
| 36 | private Integer status; | ||
| 37 | |||
| 38 | // 全名 | ||
| 39 | private String fullName; | ||
| 40 | |||
| 41 | // E-main | ||
| 42 | private String email; | ||
| 43 | |||
| 44 | // 昵称 | ||
| 45 | private String nickname; | ||
| 46 | |||
| 47 | // 性别 | ||
| 48 | private Integer sex; | ||
| 49 | |||
| 50 | // 国家 | ||
| 51 | private String country; | ||
| 52 | |||
| 53 | // 省份 | ||
| 54 | private String province; | ||
| 55 | |||
| 56 | // 城市 | ||
| 57 | private String city; | ||
| 58 | |||
| 59 | // 头像地址 | ||
| 60 | private String icon; | ||
| 61 | |||
| 62 | // 描述 | ||
| 63 | private String description; | ||
| 64 | |||
| 65 | // 创建时间 | ||
| 66 | private Timestamp createTime; | ||
| 67 | |||
| 68 | // 更新时间 | ||
| 69 | private Timestamp updateTime; | ||
| 70 | } |
| 1 | package com.topdraw.business.module.vis.hainan.apple.service.impl; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple; | ||
| 4 | import com.topdraw.business.module.vis.hainan.apple.repository.VisUserAppleRepository; | ||
| 5 | import com.topdraw.business.module.vis.hainan.apple.service.VisUserAppleService; | ||
| 6 | import com.topdraw.business.module.vis.hainan.apple.service.dto.VisUserAppleDTO; | ||
| 7 | import com.topdraw.business.module.vis.hainan.apple.service.mapper.VisUserAppleMapper; | ||
| 8 | import com.topdraw.utils.ValidationUtil; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | import org.springframework.stereotype.Service; | ||
| 11 | import org.springframework.transaction.annotation.Propagation; | ||
| 12 | import org.springframework.transaction.annotation.Transactional; | ||
| 13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 14 | import org.springframework.util.Assert; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @author XiangHan | ||
| 18 | * @date 2022-07-14 | ||
| 19 | */ | ||
| 20 | @Service | ||
| 21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 22 | public class VisUserAppleServiceImpl implements VisUserAppleService { | ||
| 23 | |||
| 24 | @Autowired | ||
| 25 | private VisUserAppleRepository visUserAppleRepository; | ||
| 26 | |||
| 27 | @Autowired | ||
| 28 | private VisUserAppleMapper visUserAppleMapper; | ||
| 29 | |||
| 30 | @Override | ||
| 31 | public VisUserAppleDTO findById(Long id) { | ||
| 32 | VisUserApple visUserApple = visUserAppleRepository.findById(id).orElseGet(VisUserApple::new); | ||
| 33 | ValidationUtil.isNull(visUserApple.getId(),"VisUserApple","id",id); | ||
| 34 | return visUserAppleMapper.toDto(visUserApple); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | @Transactional(rollbackFor = Exception.class) | ||
| 39 | public void create(VisUserApple resources) { | ||
| 40 | visUserAppleRepository.save(resources); | ||
| 41 | } | ||
| 42 | |||
| 43 | @Override | ||
| 44 | @Transactional(rollbackFor = Exception.class) | ||
| 45 | public void update(VisUserApple resources) { | ||
| 46 | VisUserApple visUserApple = visUserAppleRepository.findById(resources.getId()).orElseGet(VisUserApple::new); | ||
| 47 | ValidationUtil.isNull( visUserApple.getId(),"VisUserApple","id",resources.getId()); | ||
| 48 | visUserApple.copy(resources); | ||
| 49 | visUserAppleRepository.save(visUserApple); | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | @Transactional(rollbackFor = Exception.class) | ||
| 54 | public void delete(Long id) { | ||
| 55 | Assert.notNull(id, "The given id must not be null!"); | ||
| 56 | VisUserApple visUserApple = visUserAppleRepository.findById(id).orElseThrow( | ||
| 57 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserApple.class, id), 1)); | ||
| 58 | visUserAppleRepository.delete(visUserApple); | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | } |
| 1 | package com.topdraw.business.module.vis.hainan.apple.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple; | ||
| 5 | import com.topdraw.business.module.vis.hainan.apple.service.dto.VisUserAppleDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author XiangHan | ||
| 11 | * @date 2022-07-14 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface VisUserAppleMapper extends BaseMapper<VisUserAppleDTO, VisUserApple> { | ||
| 15 | |||
| 16 | } |
member-service-impl/src/main/java/com/topdraw/business/module/vis/hainan/qq/domain/VisUserQq.java
0 → 100644
| 1 | package com.topdraw.business.module.vis.hainan.qq.domain; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import lombok.experimental.Accessors; | ||
| 5 | import cn.hutool.core.bean.BeanUtil; | ||
| 6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 7 | import javax.persistence.*; | ||
| 8 | import org.springframework.data.annotation.CreatedDate; | ||
| 9 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 11 | import java.sql.Timestamp; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author XiangHan | ||
| 17 | * @date 2022-07-14 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="vis_user_qq") | ||
| 24 | public class VisUserQq implements Serializable { | ||
| 25 | @Transient | ||
| 26 | private String username; | ||
| 27 | @Transient | ||
| 28 | private Integer type; | ||
| 29 | // ID | ||
| 30 | @Id | ||
| 31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 32 | @Column(name = "id") | ||
| 33 | private Long id; | ||
| 34 | |||
| 35 | // 所有者ID | ||
| 36 | @Column(name = "person_id") | ||
| 37 | private Long personId; | ||
| 38 | |||
| 39 | // 用户ID | ||
| 40 | @Column(name = "vis_user_id") | ||
| 41 | private Long visUserId; | ||
| 42 | |||
| 43 | // QQunionid,针对开发者 | ||
| 44 | @Column(name = "unionid") | ||
| 45 | private String unionid; | ||
| 46 | |||
| 47 | // QQappid | ||
| 48 | @Column(name = "app_id") | ||
| 49 | private String appId; | ||
| 50 | |||
| 51 | // QQopenid | ||
| 52 | @Column(name = "openid") | ||
| 53 | private String openid; | ||
| 54 | |||
| 55 | // QQuserid | ||
| 56 | @Column(name = "user_id") | ||
| 57 | private String userId; | ||
| 58 | |||
| 59 | // 状态 0-失效 1-有效 | ||
| 60 | @Column(name = "status") | ||
| 61 | private Integer status; | ||
| 62 | |||
| 63 | // 昵称 | ||
| 64 | @Column(name = "nickname") | ||
| 65 | private String nickname; | ||
| 66 | |||
| 67 | // 性别 | ||
| 68 | @Column(name = "sex") | ||
| 69 | private Integer sex; | ||
| 70 | |||
| 71 | // 国家 | ||
| 72 | @Column(name = "country") | ||
| 73 | private String country; | ||
| 74 | |||
| 75 | // 省份 | ||
| 76 | @Column(name = "province") | ||
| 77 | private String province; | ||
| 78 | |||
| 79 | // 城市 | ||
| 80 | @Column(name = "city") | ||
| 81 | private String city; | ||
| 82 | |||
| 83 | // 头像地址 | ||
| 84 | @Column(name = "icon") | ||
| 85 | private String icon; | ||
| 86 | |||
| 87 | @Column(name = "pay_token") | ||
| 88 | private String payToken; | ||
| 89 | |||
| 90 | @Column(name = "secretType") | ||
| 91 | private String secretType; | ||
| 92 | |||
| 93 | @Column(name = "secret") | ||
| 94 | private String secret; | ||
| 95 | |||
| 96 | @Column(name = "pfkey") | ||
| 97 | private String pfkey; | ||
| 98 | |||
| 99 | @Column(name = "pf") | ||
| 100 | private String pf; | ||
| 101 | |||
| 102 | // access_token | ||
| 103 | @Column(name = "access_token") | ||
| 104 | private String accessToken; | ||
| 105 | |||
| 106 | // expires_in | ||
| 107 | @Column(name = "expires_in") | ||
| 108 | private Integer expiresIn; | ||
| 109 | |||
| 110 | // expires_time | ||
| 111 | @Column(name = "expires_time") | ||
| 112 | private Timestamp expiresTime; | ||
| 113 | |||
| 114 | // 描述 | ||
| 115 | @Column(name = "description") | ||
| 116 | private String description; | ||
| 117 | |||
| 118 | // 创建时间 | ||
| 119 | @CreatedDate | ||
| 120 | @Column(name = "create_time") | ||
| 121 | private Timestamp createTime; | ||
| 122 | |||
| 123 | // 更新时间 | ||
| 124 | @LastModifiedDate | ||
| 125 | @Column(name = "update_time") | ||
| 126 | private Timestamp updateTime; | ||
| 127 | |||
| 128 | public void copy(VisUserQq source){ | ||
| 129 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 130 | } | ||
| 131 | } |
| 1 | package com.topdraw.business.module.vis.hainan.qq.repository; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; | ||
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserQqRepository extends JpaRepository<VisUserQq, Long>, JpaSpecificationExecutor<VisUserQq> { | ||
| 12 | |||
| 13 | } |
| 1 | package com.topdraw.business.module.vis.hainan.qq.service; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; | ||
| 5 | import com.topdraw.business.module.vis.hainan.qq.service.dto.VisUserQqDTO; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserQqService { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * 根据ID查询 | ||
| 15 | * @param id ID | ||
| 16 | * @return VisUserQqDTO | ||
| 17 | */ | ||
| 18 | VisUserQqDTO findById(Long id); | ||
| 19 | |||
| 20 | void create(VisUserQq resources); | ||
| 21 | |||
| 22 | void update(VisUserQq resources); | ||
| 23 | |||
| 24 | void delete(Long id); | ||
| 25 | |||
| 26 | VisUserQqDTO findByOpenid(String account); | ||
| 27 | } |
| 1 | package com.topdraw.business.module.vis.hainan.qq.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import java.sql.Timestamp; | ||
| 5 | import java.io.Serializable; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author XiangHan | ||
| 10 | * @date 2022-07-14 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class VisUserQqDTO implements Serializable { | ||
| 14 | |||
| 15 | // ID | ||
| 16 | private Long id; | ||
| 17 | |||
| 18 | // 所有者ID | ||
| 19 | private Long personId; | ||
| 20 | |||
| 21 | // 用户ID | ||
| 22 | private Long visUserId; | ||
| 23 | |||
| 24 | // QQunionid,针对开发者 | ||
| 25 | private String unionid; | ||
| 26 | |||
| 27 | // QQappid | ||
| 28 | private String appId; | ||
| 29 | |||
| 30 | // QQopenid | ||
| 31 | private String openid; | ||
| 32 | |||
| 33 | // QQuserid | ||
| 34 | private String userId; | ||
| 35 | |||
| 36 | // 状态 0-失效 1-有效 | ||
| 37 | private Integer status; | ||
| 38 | |||
| 39 | // 昵称 | ||
| 40 | private String nickname; | ||
| 41 | |||
| 42 | // 性别 | ||
| 43 | private Integer sex; | ||
| 44 | |||
| 45 | // 国家 | ||
| 46 | private String country; | ||
| 47 | |||
| 48 | // 省份 | ||
| 49 | private String province; | ||
| 50 | |||
| 51 | // 城市 | ||
| 52 | private String city; | ||
| 53 | |||
| 54 | // 头像地址 | ||
| 55 | private String icon; | ||
| 56 | |||
| 57 | private String payToken; | ||
| 58 | |||
| 59 | private String secretType; | ||
| 60 | |||
| 61 | private String secret; | ||
| 62 | |||
| 63 | private String pfkey; | ||
| 64 | |||
| 65 | private String pf; | ||
| 66 | |||
| 67 | // access_token | ||
| 68 | private String accessToken; | ||
| 69 | |||
| 70 | // expires_in | ||
| 71 | private Integer expiresIn; | ||
| 72 | |||
| 73 | // expires_time | ||
| 74 | private Timestamp expiresTime; | ||
| 75 | |||
| 76 | // 描述 | ||
| 77 | private String description; | ||
| 78 | |||
| 79 | // 创建时间 | ||
| 80 | private Timestamp createTime; | ||
| 81 | |||
| 82 | // 更新时间 | ||
| 83 | private Timestamp updateTime; | ||
| 84 | } |
| 1 | package com.topdraw.business.module.vis.hainan.qq.service.impl; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; | ||
| 4 | import com.topdraw.business.module.vis.hainan.qq.repository.VisUserQqRepository; | ||
| 5 | import com.topdraw.business.module.vis.hainan.qq.service.VisUserQqService; | ||
| 6 | import com.topdraw.business.module.vis.hainan.qq.service.dto.VisUserQqDTO; | ||
| 7 | import com.topdraw.business.module.vis.hainan.qq.service.mapper.VisUserQqMapper; | ||
| 8 | import com.topdraw.utils.ValidationUtil; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | import org.springframework.stereotype.Service; | ||
| 11 | import org.springframework.transaction.annotation.Propagation; | ||
| 12 | import org.springframework.transaction.annotation.Transactional; | ||
| 13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 14 | import org.springframework.util.Assert; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @author XiangHan | ||
| 18 | * @date 2022-07-14 | ||
| 19 | */ | ||
| 20 | @Service | ||
| 21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 22 | public class VisUserQqServiceImpl implements VisUserQqService { | ||
| 23 | |||
| 24 | @Autowired | ||
| 25 | private VisUserQqRepository visUserQqRepository; | ||
| 26 | |||
| 27 | @Autowired | ||
| 28 | private VisUserQqMapper visUserQqMapper; | ||
| 29 | |||
| 30 | @Override | ||
| 31 | public VisUserQqDTO findById(Long id) { | ||
| 32 | VisUserQq visUserQq = visUserQqRepository.findById(id).orElseGet(VisUserQq::new); | ||
| 33 | ValidationUtil.isNull(visUserQq.getId(),"VisUserQq","id",id); | ||
| 34 | return visUserQqMapper.toDto(visUserQq); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | @Transactional(rollbackFor = Exception.class) | ||
| 39 | public void create(VisUserQq resources) { | ||
| 40 | visUserQqRepository.save(resources); | ||
| 41 | } | ||
| 42 | |||
| 43 | @Override | ||
| 44 | @Transactional(rollbackFor = Exception.class) | ||
| 45 | public void update(VisUserQq resources) { | ||
| 46 | VisUserQq visUserQq = visUserQqRepository.findById(resources.getId()).orElseGet(VisUserQq::new); | ||
| 47 | ValidationUtil.isNull( visUserQq.getId(),"VisUserQq","id",resources.getId()); | ||
| 48 | visUserQq.copy(resources); | ||
| 49 | visUserQqRepository.save(visUserQq); | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | @Transactional(rollbackFor = Exception.class) | ||
| 54 | public void delete(Long id) { | ||
| 55 | Assert.notNull(id, "The given id must not be null!"); | ||
| 56 | VisUserQq visUserQq = visUserQqRepository.findById(id).orElseThrow( | ||
| 57 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserQq.class, id), 1)); | ||
| 58 | visUserQqRepository.delete(visUserQq); | ||
| 59 | } | ||
| 60 | |||
| 61 | @Override | ||
| 62 | public VisUserQqDTO findByOpenid(String account) { | ||
| 63 | return null; | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | } |
| 1 | package com.topdraw.business.module.vis.hainan.qq.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq; | ||
| 5 | import com.topdraw.business.module.vis.hainan.qq.service.dto.VisUserQqDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author XiangHan | ||
| 11 | * @date 2022-07-14 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface VisUserQqMapper extends BaseMapper<VisUserQqDTO, VisUserQq> { | ||
| 15 | |||
| 16 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weibo.domain; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import lombok.experimental.Accessors; | ||
| 5 | import cn.hutool.core.bean.BeanUtil; | ||
| 6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 7 | import javax.persistence.*; | ||
| 8 | import org.springframework.data.annotation.CreatedDate; | ||
| 9 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 11 | import java.sql.Timestamp; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author XiangHan | ||
| 17 | * @date 2022-07-14 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="vis_user_weibo") | ||
| 24 | public class VisUserWeibo implements Serializable { | ||
| 25 | @Transient | ||
| 26 | private String username; | ||
| 27 | @Transient | ||
| 28 | private Integer type; | ||
| 29 | // ID | ||
| 30 | @Id | ||
| 31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 32 | @Column(name = "id") | ||
| 33 | private Long id; | ||
| 34 | |||
| 35 | // 所有者ID | ||
| 36 | @Column(name = "person_id") | ||
| 37 | private Long personId; | ||
| 38 | |||
| 39 | // 用户ID | ||
| 40 | @Column(name = "vis_user_id") | ||
| 41 | private Long visUserId; | ||
| 42 | |||
| 43 | // 微博appid | ||
| 44 | @Column(name = "app_id") | ||
| 45 | private String appId; | ||
| 46 | |||
| 47 | // 微博用户ID | ||
| 48 | @Column(name = "user_id") | ||
| 49 | private String userId; | ||
| 50 | |||
| 51 | // 状态 0-失效 1-有效 | ||
| 52 | @Column(name = "status") | ||
| 53 | private Integer status; | ||
| 54 | |||
| 55 | // 昵称 | ||
| 56 | @Column(name = "nickname") | ||
| 57 | private String nickname; | ||
| 58 | |||
| 59 | // 性别 | ||
| 60 | @Column(name = "sex") | ||
| 61 | private Integer sex; | ||
| 62 | |||
| 63 | // 国家 | ||
| 64 | @Column(name = "country") | ||
| 65 | private String country; | ||
| 66 | |||
| 67 | // 省份 | ||
| 68 | @Column(name = "province") | ||
| 69 | private String province; | ||
| 70 | |||
| 71 | // 城市 | ||
| 72 | @Column(name = "city") | ||
| 73 | private String city; | ||
| 74 | |||
| 75 | // 头像地址 | ||
| 76 | @Column(name = "icon") | ||
| 77 | private String icon; | ||
| 78 | |||
| 79 | // secretType | ||
| 80 | @Column(name = "secretType") | ||
| 81 | private String secretType; | ||
| 82 | |||
| 83 | // secret | ||
| 84 | @Column(name = "secret") | ||
| 85 | private String secret; | ||
| 86 | |||
| 87 | // snsregat | ||
| 88 | @Column(name = "snsregat") | ||
| 89 | private String snsregat; | ||
| 90 | |||
| 91 | // snsUserUrl | ||
| 92 | @Column(name = "snsUserUrl") | ||
| 93 | private String snsUserUrl; | ||
| 94 | |||
| 95 | // shareCount | ||
| 96 | @Column(name = "shareCount") | ||
| 97 | private String shareCount; | ||
| 98 | |||
| 99 | // followerCount | ||
| 100 | @Column(name = "followerCount") | ||
| 101 | private String followerCount; | ||
| 102 | |||
| 103 | // refresh_token | ||
| 104 | @Column(name = "refresh_token") | ||
| 105 | private String refreshToken; | ||
| 106 | |||
| 107 | // access_token | ||
| 108 | @Column(name = "access_token") | ||
| 109 | private String accessToken; | ||
| 110 | |||
| 111 | // expires_in | ||
| 112 | @Column(name = "expires_in") | ||
| 113 | private Long expiresIn; | ||
| 114 | |||
| 115 | // expires_time | ||
| 116 | @Column(name = "expires_time") | ||
| 117 | private Timestamp expiresTime; | ||
| 118 | |||
| 119 | // 描述 | ||
| 120 | @Column(name = "description") | ||
| 121 | private String description; | ||
| 122 | |||
| 123 | // 创建时间 | ||
| 124 | @CreatedDate | ||
| 125 | @Column(name = "create_time") | ||
| 126 | private Timestamp createTime; | ||
| 127 | |||
| 128 | // 更新时间 | ||
| 129 | @LastModifiedDate | ||
| 130 | @Column(name = "update_time") | ||
| 131 | private Timestamp updateTime; | ||
| 132 | |||
| 133 | public void copy(VisUserWeibo source){ | ||
| 134 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 135 | } | ||
| 136 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weibo.repository; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserWeiboRepository extends JpaRepository<VisUserWeibo, Long>, JpaSpecificationExecutor<VisUserWeibo> { | ||
| 12 | |||
| 13 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weibo.service; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 5 | import com.topdraw.business.module.vis.hainan.weibo.service.dto.VisUserWeiboDTO; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserWeiboService { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * 根据ID查询 | ||
| 15 | * @param id ID | ||
| 16 | * @return VisUserWeiboDTO | ||
| 17 | */ | ||
| 18 | VisUserWeiboDTO findById(Long id); | ||
| 19 | |||
| 20 | void create(VisUserWeibo resources); | ||
| 21 | |||
| 22 | void update(VisUserWeibo resources); | ||
| 23 | |||
| 24 | void delete(Long id); | ||
| 25 | |||
| 26 | VisUserWeiboDTO findByUserid(String account); | ||
| 27 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weibo.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import java.sql.Timestamp; | ||
| 5 | import java.io.Serializable; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author XiangHan | ||
| 10 | * @date 2022-07-14 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class VisUserWeiboDTO implements Serializable { | ||
| 14 | |||
| 15 | // ID | ||
| 16 | private Long id; | ||
| 17 | |||
| 18 | // 所有者ID | ||
| 19 | private Long personId; | ||
| 20 | |||
| 21 | // 用户ID | ||
| 22 | private Long visUserId; | ||
| 23 | |||
| 24 | // 微博appid | ||
| 25 | private String appId; | ||
| 26 | |||
| 27 | // 微博用户ID | ||
| 28 | private String userId; | ||
| 29 | |||
| 30 | // 状态 0-失效 1-有效 | ||
| 31 | private Integer status; | ||
| 32 | |||
| 33 | // 昵称 | ||
| 34 | private String nickname; | ||
| 35 | |||
| 36 | // 性别 | ||
| 37 | private Integer sex; | ||
| 38 | |||
| 39 | // 国家 | ||
| 40 | private String country; | ||
| 41 | |||
| 42 | // 省份 | ||
| 43 | private String province; | ||
| 44 | |||
| 45 | // 城市 | ||
| 46 | private String city; | ||
| 47 | |||
| 48 | // 头像地址 | ||
| 49 | private String icon; | ||
| 50 | |||
| 51 | // secretType | ||
| 52 | private String secretType; | ||
| 53 | |||
| 54 | // secret | ||
| 55 | private String secret; | ||
| 56 | |||
| 57 | // snsregat | ||
| 58 | private String snsregat; | ||
| 59 | |||
| 60 | // snsUserUrl | ||
| 61 | private String snsUserUrl; | ||
| 62 | |||
| 63 | // shareCount | ||
| 64 | private String shareCount; | ||
| 65 | |||
| 66 | // followerCount | ||
| 67 | private String followerCount; | ||
| 68 | |||
| 69 | // refresh_token | ||
| 70 | private String refreshToken; | ||
| 71 | |||
| 72 | // access_token | ||
| 73 | private String accessToken; | ||
| 74 | |||
| 75 | // expires_in | ||
| 76 | private Long expiresIn; | ||
| 77 | |||
| 78 | // expires_time | ||
| 79 | private Timestamp expiresTime; | ||
| 80 | |||
| 81 | // 描述 | ||
| 82 | private String description; | ||
| 83 | |||
| 84 | // 创建时间 | ||
| 85 | private Timestamp createTime; | ||
| 86 | |||
| 87 | // 更新时间 | ||
| 88 | private Timestamp updateTime; | ||
| 89 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weibo.service.impl; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 4 | import com.topdraw.business.module.vis.hainan.weibo.repository.VisUserWeiboRepository; | ||
| 5 | import com.topdraw.business.module.vis.hainan.weibo.service.VisUserWeiboService; | ||
| 6 | import com.topdraw.business.module.vis.hainan.weibo.service.dto.VisUserWeiboDTO; | ||
| 7 | import com.topdraw.business.module.vis.hainan.weibo.service.mapper.VisUserWeiboMapper; | ||
| 8 | import com.topdraw.utils.ValidationUtil; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | import org.springframework.stereotype.Service; | ||
| 11 | import org.springframework.transaction.annotation.Propagation; | ||
| 12 | import org.springframework.transaction.annotation.Transactional; | ||
| 13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 14 | import org.springframework.util.Assert; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @author XiangHan | ||
| 18 | * @date 2022-07-14 | ||
| 19 | */ | ||
| 20 | @Service | ||
| 21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 22 | public class VisUserWeiboServiceImpl implements VisUserWeiboService { | ||
| 23 | |||
| 24 | @Autowired | ||
| 25 | private VisUserWeiboRepository visUserWeiboRepository; | ||
| 26 | |||
| 27 | @Autowired | ||
| 28 | private VisUserWeiboMapper visUserWeiboMapper; | ||
| 29 | |||
| 30 | @Override | ||
| 31 | public VisUserWeiboDTO findById(Long id) { | ||
| 32 | VisUserWeibo visUserWeibo = visUserWeiboRepository.findById(id).orElseGet(VisUserWeibo::new); | ||
| 33 | ValidationUtil.isNull(visUserWeibo.getId(),"VisUserWeibo","id",id); | ||
| 34 | return visUserWeiboMapper.toDto(visUserWeibo); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | @Transactional(rollbackFor = Exception.class) | ||
| 39 | public void create(VisUserWeibo resources) { | ||
| 40 | visUserWeiboRepository.save(resources); | ||
| 41 | } | ||
| 42 | |||
| 43 | @Override | ||
| 44 | @Transactional(rollbackFor = Exception.class) | ||
| 45 | public void update(VisUserWeibo resources) { | ||
| 46 | VisUserWeibo visUserWeibo = visUserWeiboRepository.findById(resources.getId()).orElseGet(VisUserWeibo::new); | ||
| 47 | ValidationUtil.isNull( visUserWeibo.getId(),"VisUserWeibo","id",resources.getId()); | ||
| 48 | visUserWeibo.copy(resources); | ||
| 49 | visUserWeiboRepository.save(visUserWeibo); | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | @Transactional(rollbackFor = Exception.class) | ||
| 54 | public void delete(Long id) { | ||
| 55 | Assert.notNull(id, "The given id must not be null!"); | ||
| 56 | VisUserWeibo visUserWeibo = visUserWeiboRepository.findById(id).orElseThrow( | ||
| 57 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserWeibo.class, id), 1)); | ||
| 58 | visUserWeiboRepository.delete(visUserWeibo); | ||
| 59 | } | ||
| 60 | |||
| 61 | @Override | ||
| 62 | public VisUserWeiboDTO findByUserid(String account) { | ||
| 63 | return null; | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weibo.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo; | ||
| 5 | import com.topdraw.business.module.vis.hainan.weibo.service.dto.VisUserWeiboDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author XiangHan | ||
| 11 | * @date 2022-07-14 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface VisUserWeiboMapper extends BaseMapper<VisUserWeiboDTO, VisUserWeibo> { | ||
| 15 | |||
| 16 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weixin.domain; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import lombok.experimental.Accessors; | ||
| 5 | import cn.hutool.core.bean.BeanUtil; | ||
| 6 | import cn.hutool.core.bean.copier.CopyOptions; | ||
| 7 | import javax.persistence.*; | ||
| 8 | import org.springframework.data.annotation.CreatedDate; | ||
| 9 | import org.springframework.data.annotation.LastModifiedDate; | ||
| 10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 11 | import java.sql.Timestamp; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @author XiangHan | ||
| 17 | * @date 2022-07-14 | ||
| 18 | */ | ||
| 19 | @Entity | ||
| 20 | @Data | ||
| 21 | @EntityListeners(AuditingEntityListener.class) | ||
| 22 | @Accessors(chain = true) | ||
| 23 | @Table(name="vis_user_weixin") | ||
| 24 | public class VisUserWeixin implements Serializable { | ||
| 25 | |||
| 26 | |||
| 27 | @Transient | ||
| 28 | private String username; | ||
| 29 | @Transient | ||
| 30 | private Integer type; | ||
| 31 | |||
| 32 | // ID | ||
| 33 | @Id | ||
| 34 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 35 | @Column(name = "id") | ||
| 36 | private Long id; | ||
| 37 | |||
| 38 | // 所有者ID | ||
| 39 | @Column(name = "person_id") | ||
| 40 | private Long personId; | ||
| 41 | |||
| 42 | // 用户ID | ||
| 43 | @Column(name = "vis_user_id") | ||
| 44 | private Long visUserId; | ||
| 45 | |||
| 46 | // 微信unionid,针对开发者 | ||
| 47 | @Column(name = "unionid") | ||
| 48 | private String unionid; | ||
| 49 | |||
| 50 | // 微信appid | ||
| 51 | @Column(name = "appid") | ||
| 52 | private String appid; | ||
| 53 | |||
| 54 | // 微信appid | ||
| 55 | @Column(name = "app_id") | ||
| 56 | private String appId; | ||
| 57 | |||
| 58 | // 微信openid,针对微信app | ||
| 59 | @Column(name = "openid") | ||
| 60 | private String openid; | ||
| 61 | |||
| 62 | // 状态 0-失效 1-有效 | ||
| 63 | @Column(name = "status") | ||
| 64 | private Integer status; | ||
| 65 | |||
| 66 | // 昵称 | ||
| 67 | @Column(name = "nickname") | ||
| 68 | private String nickname; | ||
| 69 | |||
| 70 | // 性别 | ||
| 71 | @Column(name = "sex") | ||
| 72 | private Integer sex; | ||
| 73 | |||
| 74 | // 国家 | ||
| 75 | @Column(name = "country") | ||
| 76 | private String country; | ||
| 77 | |||
| 78 | // 省份 | ||
| 79 | @Column(name = "province") | ||
| 80 | private String province; | ||
| 81 | |||
| 82 | // 城市 | ||
| 83 | @Column(name = "city") | ||
| 84 | private String city; | ||
| 85 | |||
| 86 | // 头像地址 | ||
| 87 | @Column(name = "headimgurl") | ||
| 88 | private String headimgurl; | ||
| 89 | |||
| 90 | // 特权信息 | ||
| 91 | @Column(name = "privilege") | ||
| 92 | private String privilege; | ||
| 93 | |||
| 94 | // refresh_token | ||
| 95 | @Column(name = "refresh_token") | ||
| 96 | private String refreshToken; | ||
| 97 | |||
| 98 | // access_token | ||
| 99 | @Column(name = "access_token") | ||
| 100 | private String accessToken; | ||
| 101 | |||
| 102 | // expires_in | ||
| 103 | @Column(name = "expires_in") | ||
| 104 | private Integer expiresIn; | ||
| 105 | |||
| 106 | // expires_time | ||
| 107 | @Column(name = "expires_time") | ||
| 108 | private Timestamp expiresTime; | ||
| 109 | |||
| 110 | // 描述 | ||
| 111 | @Column(name = "description") | ||
| 112 | private String description; | ||
| 113 | |||
| 114 | // 创建时间 | ||
| 115 | @CreatedDate | ||
| 116 | @Column(name = "create_time") | ||
| 117 | private Timestamp createTime; | ||
| 118 | |||
| 119 | // 更新时间 | ||
| 120 | @LastModifiedDate | ||
| 121 | @Column(name = "update_time") | ||
| 122 | private Timestamp updateTime; | ||
| 123 | |||
| 124 | public void copy(VisUserWeixin source){ | ||
| 125 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
| 126 | } | ||
| 127 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weixin.repository; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
| 6 | |||
| 7 | import java.util.Optional; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author XiangHan | ||
| 11 | * @date 2022-07-14 | ||
| 12 | */ | ||
| 13 | public interface VisUserWeixinRepository extends JpaRepository<VisUserWeixin, Long>, JpaSpecificationExecutor<VisUserWeixin> { | ||
| 14 | |||
| 15 | |||
| 16 | Optional<VisUserWeixin> findByOpenid(String account); | ||
| 17 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weixin.service; | ||
| 2 | |||
| 3 | |||
| 4 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 5 | import com.topdraw.business.module.vis.hainan.weixin.service.dto.VisUserWeixinDTO; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * @author XiangHan | ||
| 9 | * @date 2022-07-14 | ||
| 10 | */ | ||
| 11 | public interface VisUserWeixinService { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * 根据ID查询 | ||
| 15 | * @param id ID | ||
| 16 | * @return VisUserWeixinDTO | ||
| 17 | */ | ||
| 18 | VisUserWeixinDTO findById(Long id); | ||
| 19 | |||
| 20 | void create(VisUserWeixin resources); | ||
| 21 | |||
| 22 | void update(VisUserWeixin resources); | ||
| 23 | |||
| 24 | void delete(Long id); | ||
| 25 | |||
| 26 | VisUserWeixinDTO findByOpenid(String account); | ||
| 27 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weixin.service.dto; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import java.sql.Timestamp; | ||
| 5 | import java.io.Serializable; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * @author XiangHan | ||
| 10 | * @date 2022-07-14 | ||
| 11 | */ | ||
| 12 | @Data | ||
| 13 | public class VisUserWeixinDTO implements Serializable { | ||
| 14 | |||
| 15 | |||
| 16 | // ID | ||
| 17 | private Long id; | ||
| 18 | |||
| 19 | // 所有者ID | ||
| 20 | private Long personId; | ||
| 21 | |||
| 22 | // 用户ID | ||
| 23 | private Long visUserId; | ||
| 24 | |||
| 25 | // 微信unionid,针对开发者 | ||
| 26 | private String unionid; | ||
| 27 | |||
| 28 | // 微信appid | ||
| 29 | private String appid; | ||
| 30 | |||
| 31 | // 微信appid | ||
| 32 | private String appId; | ||
| 33 | |||
| 34 | // 微信openid,针对微信app | ||
| 35 | private String openid; | ||
| 36 | |||
| 37 | // 状态 0-失效 1-有效 | ||
| 38 | private Integer status; | ||
| 39 | |||
| 40 | // 昵称 | ||
| 41 | private String nickname; | ||
| 42 | |||
| 43 | // 性别 | ||
| 44 | private Integer sex; | ||
| 45 | |||
| 46 | // 国家 | ||
| 47 | private String country; | ||
| 48 | |||
| 49 | // 省份 | ||
| 50 | private String province; | ||
| 51 | |||
| 52 | // 城市 | ||
| 53 | private String city; | ||
| 54 | |||
| 55 | // 头像地址 | ||
| 56 | private String headimgurl; | ||
| 57 | |||
| 58 | // 特权信息 | ||
| 59 | private String privilege; | ||
| 60 | |||
| 61 | // refresh_token | ||
| 62 | private String refreshToken; | ||
| 63 | |||
| 64 | // access_token | ||
| 65 | private String accessToken; | ||
| 66 | |||
| 67 | // expires_in | ||
| 68 | private Integer expiresIn; | ||
| 69 | |||
| 70 | // expires_time | ||
| 71 | private Timestamp expiresTime; | ||
| 72 | |||
| 73 | // 描述 | ||
| 74 | private String description; | ||
| 75 | |||
| 76 | // 创建时间 | ||
| 77 | private Timestamp createTime; | ||
| 78 | |||
| 79 | // 更新时间 | ||
| 80 | private Timestamp updateTime; | ||
| 81 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weixin.service.impl; | ||
| 2 | |||
| 3 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 4 | import com.topdraw.business.module.vis.hainan.weixin.repository.VisUserWeixinRepository; | ||
| 5 | import com.topdraw.business.module.vis.hainan.weixin.service.VisUserWeixinService; | ||
| 6 | import com.topdraw.business.module.vis.hainan.weixin.service.dto.VisUserWeixinDTO; | ||
| 7 | import com.topdraw.business.module.vis.hainan.weixin.service.mapper.VisUserWeixinMapper; | ||
| 8 | import com.topdraw.utils.ValidationUtil; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | import org.springframework.stereotype.Service; | ||
| 11 | import org.springframework.transaction.annotation.Propagation; | ||
| 12 | import org.springframework.transaction.annotation.Transactional; | ||
| 13 | import org.springframework.dao.EmptyResultDataAccessException; | ||
| 14 | import org.springframework.util.Assert; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @author XiangHan | ||
| 18 | * @date 2022-07-14 | ||
| 19 | */ | ||
| 20 | @Service | ||
| 21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
| 22 | public class VisUserWeixinServiceImpl implements VisUserWeixinService { | ||
| 23 | |||
| 24 | @Autowired | ||
| 25 | private VisUserWeixinRepository visUserWeixinRepository; | ||
| 26 | |||
| 27 | @Autowired | ||
| 28 | private VisUserWeixinMapper visUserWeixinMapper; | ||
| 29 | |||
| 30 | @Override | ||
| 31 | public VisUserWeixinDTO findById(Long id) { | ||
| 32 | VisUserWeixin visUserWeixin = visUserWeixinRepository.findById(id).orElseGet(VisUserWeixin::new); | ||
| 33 | ValidationUtil.isNull(visUserWeixin.getId(),"VisUserWeixin","id",id); | ||
| 34 | return visUserWeixinMapper.toDto(visUserWeixin); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | @Transactional(rollbackFor = Exception.class) | ||
| 39 | public void create(VisUserWeixin resources) { | ||
| 40 | visUserWeixinRepository.save(resources); | ||
| 41 | } | ||
| 42 | |||
| 43 | @Override | ||
| 44 | @Transactional(rollbackFor = Exception.class) | ||
| 45 | public void update(VisUserWeixin resources) { | ||
| 46 | VisUserWeixin visUserWeixin = visUserWeixinRepository.findById(resources.getId()).orElseGet(VisUserWeixin::new); | ||
| 47 | ValidationUtil.isNull( visUserWeixin.getId(),"VisUserWeixin","id",resources.getId()); | ||
| 48 | visUserWeixin.copy(resources); | ||
| 49 | visUserWeixinRepository.save(visUserWeixin); | ||
| 50 | } | ||
| 51 | |||
| 52 | @Override | ||
| 53 | @Transactional(rollbackFor = Exception.class) | ||
| 54 | public void delete(Long id) { | ||
| 55 | Assert.notNull(id, "The given id must not be null!"); | ||
| 56 | VisUserWeixin visUserWeixin = visUserWeixinRepository.findById(id).orElseThrow( | ||
| 57 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserWeixin.class, id), 1)); | ||
| 58 | visUserWeixinRepository.delete(visUserWeixin); | ||
| 59 | } | ||
| 60 | |||
| 61 | @Override | ||
| 62 | public VisUserWeixinDTO findByOpenid(String account) { | ||
| 63 | VisUserWeixin visUserWeixin = visUserWeixinRepository.findByOpenid(account).orElseGet(VisUserWeixin::new); | ||
| 64 | return visUserWeixinMapper.toDto(visUserWeixin); | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | } |
| 1 | package com.topdraw.business.module.vis.hainan.weixin.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin; | ||
| 5 | import com.topdraw.business.module.vis.hainan.weixin.service.dto.VisUserWeixinDTO; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.ReportingPolicy; | ||
| 8 | |||
| 9 | /** | ||
| 10 | * @author XiangHan | ||
| 11 | * @date 2022-07-14 | ||
| 12 | */ | ||
| 13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 14 | public interface VisUserWeixinMapper extends BaseMapper<VisUserWeixinDTO, VisUserWeixin> { | ||
| 15 | |||
| 16 | } |
| ... | @@ -5,7 +5,7 @@ spring: | ... | @@ -5,7 +5,7 @@ spring: |
| 5 | # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 5 | # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
| 6 | # username: root | 6 | # username: root |
| 7 | # password: root | 7 | # password: root |
| 8 | url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_admin_chongshu?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 8 | url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_stage_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
| 9 | username: root | 9 | username: root |
| 10 | password: Tjlh@2021 | 10 | password: Tjlh@2021 |
| 11 | 11 | ... | ... |
-
Please register or sign in to post a comment