1.修改绑定、解绑实现
Showing
18 changed files
with
789 additions
and
3 deletions
member-service-impl/src/main/java/com/topdraw/business/module/member/domain/MemberTypeConstant.java
0 → 100644
1 | package com.topdraw.business.module.member.domain; | ||
2 | |||
3 | /** | ||
4 | * @author : | ||
5 | * @description: | ||
6 | * @function : | ||
7 | * @date :Created in 2022/6/27 15:38 | ||
8 | * @version: : | ||
9 | * @modified By: | ||
10 | * @since : modified in 2022/6/27 15:38 | ||
11 | */ | ||
12 | public interface MemberTypeConstant { | ||
13 | |||
14 | // 大屏 | ||
15 | Integer vis = 1; | ||
16 | // 微信 | ||
17 | Integer weixin = 2; | ||
18 | // app | ||
19 | Integer app = 3; | ||
20 | } |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/domain/UserApp.java
0 → 100644
1 | package com.topdraw.business.module.user.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-06-27 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_user_app") | ||
24 | public class UserApp 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 = "member_id") | ||
34 | private Long memberId; | ||
35 | |||
36 | // 用户名(一般为手机号) | ||
37 | @Column(name = "username", nullable = false) | ||
38 | private String username; | ||
39 | |||
40 | // 密码 | ||
41 | @Column(name = "password") | ||
42 | private String password; | ||
43 | |||
44 | // 类型 0:苹果;1:安卓;-1:未知 | ||
45 | @Column(name = "type", nullable = false) | ||
46 | private Integer type; | ||
47 | |||
48 | // 状态 0:禁用;1:生效;-1:注销 | ||
49 | @Column(name = "status", nullable = false) | ||
50 | private Integer status; | ||
51 | |||
52 | // 昵称 | ||
53 | @Column(name = "nickname") | ||
54 | private String nickname; | ||
55 | |||
56 | // 头像地址 | ||
57 | @Column(name = "headimgurl") | ||
58 | private String headimgurl; | ||
59 | |||
60 | // 邮箱 | ||
61 | @Column(name = "email") | ||
62 | private String email; | ||
63 | |||
64 | // 手机号 | ||
65 | @Column(name = "cellphone") | ||
66 | private String cellphone; | ||
67 | |||
68 | // 性别 0:女;1:男;-1:其他 | ||
69 | @Column(name = "gender") | ||
70 | private Integer gender; | ||
71 | |||
72 | // 生日 | ||
73 | @Column(name = "birthday") | ||
74 | private String birthday; | ||
75 | |||
76 | // 最近活跃时间 | ||
77 | @Column(name = "last_active_time") | ||
78 | private Timestamp lastActiveTime; | ||
79 | |||
80 | // 注销时间 | ||
81 | @Column(name = "delete_time") | ||
82 | private Timestamp deleteTime; | ||
83 | |||
84 | // 标签 | ||
85 | @Column(name = "tags") | ||
86 | private String tags; | ||
87 | |||
88 | // 描述 | ||
89 | @Column(name = "description") | ||
90 | private String description; | ||
91 | |||
92 | // 创建时间 | ||
93 | @CreatedDate | ||
94 | @Column(name = "create_time") | ||
95 | private Timestamp createTime; | ||
96 | |||
97 | // 更新时间 | ||
98 | @LastModifiedDate | ||
99 | @Column(name = "update_time") | ||
100 | private Timestamp updateTime; | ||
101 | |||
102 | public void copy(UserApp source){ | ||
103 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
104 | } | ||
105 | } |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/domain/UserAppBind.java
0 → 100644
1 | package com.topdraw.business.module.user.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-06-27 | ||
18 | */ | ||
19 | @Entity | ||
20 | @Data | ||
21 | @EntityListeners(AuditingEntityListener.class) | ||
22 | @Accessors(chain = true) | ||
23 | @Table(name="uc_user_app_bind") | ||
24 | public class UserAppBind implements Serializable { | ||
25 | |||
26 | // 主键 | ||
27 | @Id | ||
28 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
29 | @Column(name = "id") | ||
30 | private Long id; | ||
31 | |||
32 | // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号 | ||
33 | @Column(name = "account_type", nullable = false) | ||
34 | private Integer accountType; | ||
35 | |||
36 | // 第三方账号 | ||
37 | @Column(name = "account", nullable = false) | ||
38 | private String account; | ||
39 | |||
40 | // app账号id | ||
41 | @Column(name = "user_app_id", nullable = false) | ||
42 | private Long userAppId; | ||
43 | |||
44 | // 创建时间 | ||
45 | @CreatedDate | ||
46 | @Column(name = "create_time") | ||
47 | private Timestamp createTime; | ||
48 | |||
49 | // 更新时间 | ||
50 | @LastModifiedDate | ||
51 | @Column(name = "update_time") | ||
52 | private Timestamp updateTime; | ||
53 | |||
54 | public void copy(UserAppBind source){ | ||
55 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ||
56 | } | ||
57 | } |
1 | package com.topdraw.business.module.user.app.repository; | ||
2 | |||
3 | import com.topdraw.business.module.user.app.domain.UserAppBind; | ||
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-06-27 | ||
12 | */ | ||
13 | public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, JpaSpecificationExecutor<UserAppBind> { | ||
14 | |||
15 | } |
1 | package com.topdraw.business.module.user.app.repository; | ||
2 | |||
3 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
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-06-27 | ||
12 | */ | ||
13 | public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpecificationExecutor<UserApp> { | ||
14 | |||
15 | Optional<UserApp> findByUsername(String username); | ||
16 | |||
17 | Optional<UserApp> findByUsernameAndPassword(String username, String password); | ||
18 | |||
19 | } |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/rest/UserAppController.java
0 → 100644
1 | package com.topdraw.business.module.user.app.rest; | ||
2 | |||
3 | import com.topdraw.annotation.AnonymousAccess; | ||
4 | import com.topdraw.common.ResultInfo; | ||
5 | import com.topdraw.annotation.Log; | ||
6 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
7 | import com.topdraw.business.module.user.app.service.UserAppService; | ||
8 | import lombok.extern.slf4j.Slf4j; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | ||
10 | import org.springframework.validation.annotation.Validated; | ||
11 | import org.springframework.web.bind.annotation.*; | ||
12 | import io.swagger.annotations.*; | ||
13 | |||
14 | /** | ||
15 | * @author XiangHan | ||
16 | * @date 2022-06-27 | ||
17 | */ | ||
18 | @Api(tags = "UserApp管理") | ||
19 | @RestController | ||
20 | @RequestMapping("/uce/userApp") | ||
21 | @Slf4j | ||
22 | public class UserAppController { | ||
23 | |||
24 | @Autowired | ||
25 | private UserAppService userAppService; | ||
26 | |||
27 | @Log | ||
28 | @PostMapping | ||
29 | @ApiOperation("新增UserApp") | ||
30 | @AnonymousAccess | ||
31 | public ResultInfo create(@Validated @RequestBody UserApp resources) { | ||
32 | log.info("新增App账号 ==>> param ==>> [addLogin#{}]", resources); | ||
33 | |||
34 | this.userAppService.create(resources); | ||
35 | return ResultInfo.success(); | ||
36 | } | ||
37 | |||
38 | @Log | ||
39 | @PutMapping | ||
40 | @ApiOperation("修改UserApp") | ||
41 | @AnonymousAccess | ||
42 | public ResultInfo update(@Validated @RequestBody UserApp resources) { | ||
43 | this.userAppService.update(resources); | ||
44 | return ResultInfo.success(); | ||
45 | } | ||
46 | |||
47 | |||
48 | @Log | ||
49 | @DeleteMapping(value = "/{id}") | ||
50 | @ApiOperation("删除UserApp") | ||
51 | @AnonymousAccess | ||
52 | public ResultInfo delete(@PathVariable Long id) { | ||
53 | this.userAppService.delete(id); | ||
54 | return ResultInfo.success(); | ||
55 | } | ||
56 | |||
57 | } |
1 | package com.topdraw.business.module.user.app.service; | ||
2 | |||
3 | import com.topdraw.business.module.user.app.domain.UserAppBind; | ||
4 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | ||
5 | |||
6 | /** | ||
7 | * @author XiangHan | ||
8 | * @date 2022-06-27 | ||
9 | */ | ||
10 | public interface UserAppBindService { | ||
11 | |||
12 | /** | ||
13 | * 根据ID查询 | ||
14 | * @param id ID | ||
15 | * @return UserAppBindDTO | ||
16 | */ | ||
17 | UserAppBindDTO findById(Long id); | ||
18 | |||
19 | /** | ||
20 | * | ||
21 | * @param resources | ||
22 | */ | ||
23 | void create(UserAppBind resources); | ||
24 | |||
25 | /** | ||
26 | * | ||
27 | * @param resources | ||
28 | */ | ||
29 | void update(UserAppBind resources); | ||
30 | |||
31 | /** | ||
32 | * | ||
33 | * @param id | ||
34 | */ | ||
35 | void delete(Long id); | ||
36 | |||
37 | } |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/service/UserAppService.java
0 → 100644
1 | package com.topdraw.business.module.user.app.service; | ||
2 | |||
3 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
4 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; | ||
5 | |||
6 | /** | ||
7 | * @author XiangHan | ||
8 | * @date 2022-06-27 | ||
9 | */ | ||
10 | public interface UserAppService { | ||
11 | |||
12 | /** | ||
13 | * 根据ID查询 | ||
14 | * @param id ID | ||
15 | * @return UserAppDTO | ||
16 | */ | ||
17 | UserAppDTO findById(Long id); | ||
18 | |||
19 | /** | ||
20 | * 检查账号和秘密 | ||
21 | * @param username | ||
22 | * @return | ||
23 | */ | ||
24 | UserAppDTO findByUserName(String username); | ||
25 | |||
26 | |||
27 | /** | ||
28 | * 检查账号和秘密 | ||
29 | * @param username | ||
30 | * @param password | ||
31 | * @return | ||
32 | */ | ||
33 | UserAppDTO findByUserNameAndPassword(String username, String password); | ||
34 | |||
35 | /** | ||
36 | * 检查账号和验证码 | ||
37 | * @param username | ||
38 | * @param VerificationCode | ||
39 | * @return | ||
40 | */ | ||
41 | UserAppDTO findByUserNameAndVerificationCode(String username, String VerificationCode); | ||
42 | |||
43 | /** | ||
44 | * 检查通过第三方账号 | ||
45 | * @param relationAccount | ||
46 | * @return | ||
47 | */ | ||
48 | UserAppDTO findByRelationAccount(String relationAccount); | ||
49 | |||
50 | /** | ||
51 | * | ||
52 | * @param resources | ||
53 | */ | ||
54 | UserAppDTO create(UserApp resources); | ||
55 | |||
56 | /** | ||
57 | * | ||
58 | * @param resources | ||
59 | */ | ||
60 | UserAppDTO update(UserApp resources); | ||
61 | |||
62 | /** | ||
63 | * | ||
64 | * @param id | ||
65 | */ | ||
66 | void delete(Long id); | ||
67 | |||
68 | } |
1 | package com.topdraw.business.module.user.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-06-27 | ||
11 | */ | ||
12 | @Data | ||
13 | public class UserAppBindDTO implements Serializable { | ||
14 | |||
15 | // 主键 | ||
16 | private Long id; | ||
17 | |||
18 | // 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号 | ||
19 | private Integer accountType; | ||
20 | |||
21 | // 第三方账号 | ||
22 | private String account; | ||
23 | |||
24 | // app账号id | ||
25 | private Long userAppId; | ||
26 | |||
27 | // 创建时间 | ||
28 | private Timestamp createTime; | ||
29 | |||
30 | // 更新时间 | ||
31 | private Timestamp updateTime; | ||
32 | } |
member-service-impl/src/main/java/com/topdraw/business/module/user/app/service/dto/UserAppDTO.java
0 → 100644
1 | package com.topdraw.business.module.user.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-06-27 | ||
11 | */ | ||
12 | @Data | ||
13 | public class UserAppDTO implements Serializable { | ||
14 | |||
15 | // ID | ||
16 | private Long id; | ||
17 | |||
18 | // 会员id | ||
19 | private Long memberId; | ||
20 | |||
21 | // 用户名(一般为手机号) | ||
22 | private String username; | ||
23 | |||
24 | // 密码 | ||
25 | private String password; | ||
26 | |||
27 | // 类型 0:苹果;1:安卓;-1:未知 | ||
28 | private Integer type; | ||
29 | |||
30 | // 状态 0:禁用;1:生效;-1:注销 | ||
31 | private Integer status; | ||
32 | |||
33 | // 昵称 | ||
34 | private String nickname; | ||
35 | |||
36 | // 头像地址 | ||
37 | private String headimgurl; | ||
38 | |||
39 | // 邮箱 | ||
40 | private String email; | ||
41 | |||
42 | // 手机号 | ||
43 | private String cellphone; | ||
44 | |||
45 | // 性别 0:女;1:男;-1:其他 | ||
46 | private Integer gender; | ||
47 | |||
48 | // 生日 | ||
49 | private String birthday; | ||
50 | |||
51 | // 最近活跃时间 | ||
52 | private Timestamp lastActiveTime; | ||
53 | |||
54 | // 注销时间 | ||
55 | private Timestamp deleteTime; | ||
56 | |||
57 | // 标签 | ||
58 | private String tags; | ||
59 | |||
60 | // 描述 | ||
61 | private String description; | ||
62 | |||
63 | // 创建时间 | ||
64 | private Timestamp createTime; | ||
65 | |||
66 | // 更新时间 | ||
67 | private Timestamp updateTime; | ||
68 | } |
1 | package com.topdraw.business.module.user.app.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.user.app.domain.UserAppBind; | ||
4 | import com.topdraw.utils.ValidationUtil; | ||
5 | import com.topdraw.business.module.user.app.repository.UserAppBindRepository; | ||
6 | import com.topdraw.business.module.user.app.service.UserAppBindService; | ||
7 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | ||
8 | import com.topdraw.business.module.user.app.service.mapper.UserAppBindMapper; | ||
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.data.domain.Page; | ||
15 | import org.springframework.data.domain.Pageable; | ||
16 | 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 | |||
23 | /** | ||
24 | * @author XiangHan | ||
25 | * @date 2022-06-27 | ||
26 | */ | ||
27 | @Service | ||
28 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
29 | public class UserAppBindServiceImpl implements UserAppBindService { | ||
30 | |||
31 | @Autowired | ||
32 | private UserAppBindRepository userAppBindRepository; | ||
33 | |||
34 | @Autowired | ||
35 | private UserAppBindMapper userAppBindMapper; | ||
36 | |||
37 | @Override | ||
38 | public UserAppBindDTO findById(Long id) { | ||
39 | UserAppBind userAppBind = this.userAppBindRepository.findById(id).orElseGet(UserAppBind::new); | ||
40 | ValidationUtil.isNull(userAppBind.getId(),"UserAppBind","id",id); | ||
41 | return this.userAppBindMapper.toDto(userAppBind); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | @Transactional(rollbackFor = Exception.class) | ||
46 | public void create(UserAppBind resources) { | ||
47 | this.userAppBindRepository.save(resources); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | @Transactional(rollbackFor = Exception.class) | ||
52 | public void update(UserAppBind resources) { | ||
53 | UserAppBind userAppBind = this.userAppBindRepository.findById(resources.getId()).orElseGet(UserAppBind::new); | ||
54 | ValidationUtil.isNull( userAppBind.getId(),"UserAppBind","id",resources.getId()); | ||
55 | userAppBind.copy(resources); | ||
56 | this.userAppBindRepository.save(userAppBind); | ||
57 | } | ||
58 | |||
59 | @Override | ||
60 | @Transactional(rollbackFor = Exception.class) | ||
61 | public void delete(Long id) { | ||
62 | Assert.notNull(id, "The given id must not be null!"); | ||
63 | UserAppBind UserAppBind = this.userAppBindRepository.findById(id).orElseThrow( | ||
64 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserAppBind.class, id), 1)); | ||
65 | this.userAppBindRepository.delete(UserAppBind); | ||
66 | } | ||
67 | |||
68 | |||
69 | } |
1 | package com.topdraw.business.module.user.app.service.impl; | ||
2 | |||
3 | import com.topdraw.business.module.member.domain.Member; | ||
4 | import com.topdraw.business.module.member.domain.MemberBuilder; | ||
5 | import com.topdraw.business.module.member.domain.MemberTypeConstant; | ||
6 | import com.topdraw.business.module.member.service.MemberService; | ||
7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
8 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
9 | import com.topdraw.utils.ValidationUtil; | ||
10 | import com.topdraw.business.module.user.app.repository.UserAppRepository; | ||
11 | import com.topdraw.business.module.user.app.service.UserAppService; | ||
12 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; | ||
13 | import com.topdraw.business.module.user.app.service.mapper.UserAppMapper; | ||
14 | import lombok.extern.slf4j.Slf4j; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | ||
16 | import org.springframework.stereotype.Service; | ||
17 | import org.springframework.transaction.annotation.Propagation; | ||
18 | import org.springframework.transaction.annotation.Transactional; | ||
19 | import org.springframework.dao.EmptyResultDataAccessException; | ||
20 | import org.springframework.util.Assert; | ||
21 | |||
22 | import java.util.Objects; | ||
23 | |||
24 | /** | ||
25 | * @author XiangHan | ||
26 | * @date 2022-06-27 | ||
27 | */ | ||
28 | @Service | ||
29 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
30 | @Slf4j | ||
31 | public class UserAppServiceImpl implements UserAppService { | ||
32 | |||
33 | @Autowired | ||
34 | private UserAppRepository userAppRepository; | ||
35 | @Autowired | ||
36 | private UserAppMapper userAppMapper; | ||
37 | @Autowired | ||
38 | private MemberService memberService; | ||
39 | |||
40 | |||
41 | @Override | ||
42 | @Transactional(readOnly = true) | ||
43 | public UserAppDTO findById(Long id) { | ||
44 | UserApp userApp = this.userAppRepository.findById(id).orElseGet(UserApp::new); | ||
45 | ValidationUtil.isNull(userApp.getId(),"UserApp","id",id); | ||
46 | return this.userAppMapper.toDto(userApp); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | @Transactional(readOnly = true) | ||
51 | public UserAppDTO findByUserName(String username) { | ||
52 | UserApp userApp = this.userAppRepository.findByUsername(username).orElseGet(UserApp::new); | ||
53 | return this.userAppMapper.toDto(userApp); | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | @Transactional(readOnly = true) | ||
58 | public UserAppDTO findByUserNameAndPassword(String username, String password) { | ||
59 | UserApp userApp = this.userAppRepository.findByUsernameAndPassword(username, password).orElseGet(UserApp::new); | ||
60 | return this.userAppMapper.toDto(userApp); | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | @Transactional(readOnly = true) | ||
65 | public UserAppDTO findByUserNameAndVerificationCode(String username, String VerificationCode) { | ||
66 | UserApp userApp = null; | ||
67 | return this.userAppMapper.toDto(userApp); | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | @Transactional(readOnly = true) | ||
72 | public UserAppDTO findByRelationAccount(String relationAccount) { | ||
73 | return null; | ||
74 | } | ||
75 | |||
76 | @Override | ||
77 | @Transactional(rollbackFor = Exception.class) | ||
78 | public UserAppDTO create(UserApp resources) { | ||
79 | UserApp userApp = this.userAppRepository.save(resources); | ||
80 | return this.userAppMapper.toDto(userApp); | ||
81 | } | ||
82 | |||
83 | @Override | ||
84 | @Transactional(rollbackFor = Exception.class) | ||
85 | public UserAppDTO update(UserApp resources) { | ||
86 | UserApp userApp = this.userAppRepository.findById(resources.getId()).orElseGet(UserApp::new); | ||
87 | ValidationUtil.isNull( userApp.getId(),"UserApp","id",resources.getId()); | ||
88 | userApp.copy(resources); | ||
89 | UserApp _userApp = this.userAppRepository.save(userApp); | ||
90 | if (Objects.nonNull(_userApp.getId())) { | ||
91 | return this.userAppMapper.toDto(_userApp); | ||
92 | } | ||
93 | |||
94 | return this.userAppMapper.toDto(resources); | ||
95 | } | ||
96 | |||
97 | @Override | ||
98 | @Transactional(rollbackFor = Exception.class) | ||
99 | public void delete(Long id) { | ||
100 | Assert.notNull(id, "The given id must not be null!"); | ||
101 | UserApp UserApp = this.userAppRepository.findById(id).orElseThrow( | ||
102 | () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserApp.class, id), 1)); | ||
103 | this.userAppRepository.delete(UserApp); | ||
104 | } | ||
105 | |||
106 | |||
107 | } |
1 | package com.topdraw.business.module.user.app.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.user.app.domain.UserAppBind; | ||
5 | import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2022-06-27 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface UserAppBindMapper extends BaseMapper<UserAppBindDTO, UserAppBind> { | ||
15 | |||
16 | } |
1 | package com.topdraw.business.module.user.app.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
5 | import com.topdraw.business.module.user.app.service.dto.UserAppDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2022-06-27 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface UserAppMapper extends BaseMapper<UserAppDTO, UserApp> { | ||
15 | |||
16 | } |
... | @@ -5,11 +5,13 @@ import cn.hutool.core.util.StrUtil; | ... | @@ -5,11 +5,13 @@ import cn.hutool.core.util.StrUtil; |
5 | 5 | ||
6 | import com.alibaba.fastjson.JSONObject; | 6 | import com.alibaba.fastjson.JSONObject; |
7 | import com.topdraw.annotation.AnonymousAccess; | 7 | import com.topdraw.annotation.AnonymousAccess; |
8 | import com.topdraw.annotation.Log; | ||
8 | import com.topdraw.business.module.common.validated.CreateGroup; | 9 | import com.topdraw.business.module.common.validated.CreateGroup; |
9 | import com.topdraw.business.module.common.validated.UpdateGroup; | 10 | import com.topdraw.business.module.common.validated.UpdateGroup; |
10 | import com.topdraw.business.module.member.domain.Member; | 11 | import com.topdraw.business.module.member.domain.Member; |
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; |
14 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
13 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 15 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
14 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 16 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
15 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 17 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
... | @@ -66,6 +68,74 @@ public class UserOperationController { | ... | @@ -66,6 +68,74 @@ public class UserOperationController { |
66 | private static final String UNSUBSCRIBE = "unsubscribe"; | 68 | private static final String UNSUBSCRIBE = "unsubscribe"; |
67 | private static final Integer SUBSCRIBE_STATUS = 1; | 69 | private static final Integer SUBSCRIBE_STATUS = 1; |
68 | 70 | ||
71 | |||
72 | |||
73 | /******************************************************* APP ************************************/ | ||
74 | |||
75 | @Log | ||
76 | @PostMapping(value = "/appLogin") | ||
77 | @ApiOperation("app登录") | ||
78 | @AnonymousAccess | ||
79 | public ResultInfo appLogin(@Validated @RequestBody UserApp resources) { | ||
80 | log.info("新增App账号 ==>> param ==>> [addLogin#{}]", resources); | ||
81 | |||
82 | this.userOperationService.appLogin(resources); | ||
83 | return ResultInfo.success(); | ||
84 | } | ||
85 | |||
86 | @Log | ||
87 | @PostMapping(value = "/appLogin") | ||
88 | @ApiOperation("app登录") | ||
89 | @AnonymousAccess | ||
90 | public ResultInfo updateAppCount(@Validated @RequestBody UserApp resources) { | ||
91 | log.info("新增App账号 ==>> param ==>> [addLogin#{}]", resources); | ||
92 | |||
93 | this.userOperationService.appLogin(resources); | ||
94 | return ResultInfo.success(); | ||
95 | } | ||
96 | |||
97 | @PostMapping("/appBind") | ||
98 | @ApiOperation("微信小程序绑定大屏") | ||
99 | @AnonymousAccess | ||
100 | public ResultInfo appBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { | ||
101 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources); | ||
102 | |||
103 | Long memberId = resources.getMemberId(); | ||
104 | if (Objects.isNull(memberId)) { | ||
105 | return ResultInfo.failure("参数错误,memberId 不存在"); | ||
106 | } | ||
107 | |||
108 | String platformAccount = resources.getPlatformAccount(); | ||
109 | if (StringUtils.isBlank(platformAccount)) { | ||
110 | return ResultInfo.failure("参数错误,大屏账号不存在"); | ||
111 | } | ||
112 | |||
113 | boolean result = this.userOperationService.appBind(resources); | ||
114 | return ResultInfo.success(result); | ||
115 | } | ||
116 | |||
117 | @PostMapping("/appUnbind") | ||
118 | @ApiOperation("小屏解绑") | ||
119 | @AnonymousAccess | ||
120 | public ResultInfo appUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { | ||
121 | log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); | ||
122 | |||
123 | Long memberId = weixinUnBindBean.getMemberId(); | ||
124 | if (Objects.isNull(memberId)) { | ||
125 | log.error("小屏解绑失败,参数错误,memberId不存在"); | ||
126 | return ResultInfo.failure("参数错误,会员id不存在"); | ||
127 | } | ||
128 | boolean b = this.userOperationService.minaUnbind(weixinUnBindBean); | ||
129 | if (b) { | ||
130 | return ResultInfo.success("解绑成功"); | ||
131 | } else { | ||
132 | return ResultInfo.failure("解绑失败"); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | |||
137 | /******************************************************* weixin ************************************/ | ||
138 | |||
69 | @PutMapping(value = "/updateWeixin") | 139 | @PutMapping(value = "/updateWeixin") |
70 | @ApiOperation("修改UserWeixin") | 140 | @ApiOperation("修改UserWeixin") |
71 | @AnonymousAccess | 141 | @AnonymousAccess |
... | @@ -566,6 +636,7 @@ public class UserOperationController { | ... | @@ -566,6 +636,7 @@ public class UserOperationController { |
566 | return ResultInfo.success(); | 636 | return ResultInfo.success(); |
567 | } | 637 | } |
568 | 638 | ||
639 | |||
569 | } | 640 | } |
570 | 641 | ||
571 | 642 | ... | ... |
1 | package com.topdraw.business.process.service; | 1 | 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.iptv.domain.UserTv; | 5 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
5 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 6 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
6 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 7 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
... | @@ -113,6 +114,13 @@ public interface UserOperationService { | ... | @@ -113,6 +114,13 @@ public interface UserOperationService { |
113 | boolean minaBind(BindBean resources); | 114 | boolean minaBind(BindBean resources); |
114 | 115 | ||
115 | /** | 116 | /** |
117 | * app绑定大屏 | ||
118 | * @param resources | ||
119 | * @return | ||
120 | */ | ||
121 | boolean appBind(BindBean resources); | ||
122 | |||
123 | /** | ||
116 | * | 124 | * |
117 | * @param memberDTO | 125 | * @param memberDTO |
118 | * @param platformAccount | 126 | * @param platformAccount |
... | @@ -160,4 +168,10 @@ public interface UserOperationService { | ... | @@ -160,4 +168,10 @@ public interface UserOperationService { |
160 | */ | 168 | */ |
161 | UserTvDTO updateUserTv(UserTv resources); | 169 | UserTvDTO updateUserTv(UserTv resources); |
162 | 170 | ||
171 | /** | ||
172 | * | ||
173 | * @param resources | ||
174 | */ | ||
175 | void appLogin(UserApp resources); | ||
176 | |||
163 | } | 177 | } | ... | ... |
... | @@ -11,6 +11,7 @@ import com.topdraw.business.module.member.domain.MemberBuilder; | ... | @@ -11,6 +11,7 @@ import com.topdraw.business.module.member.domain.MemberBuilder; |
11 | import com.topdraw.business.module.member.service.MemberService; | 11 | import com.topdraw.business.module.member.service.MemberService; |
12 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 12 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
13 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | 13 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; |
14 | import com.topdraw.business.module.user.app.domain.UserApp; | ||
14 | import com.topdraw.business.module.user.iptv.domain.UserConstant; | 15 | import com.topdraw.business.module.user.iptv.domain.UserConstant; |
15 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 16 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
16 | import com.topdraw.business.module.user.iptv.domain.UserTvBuilder; | 17 | import com.topdraw.business.module.user.iptv.domain.UserTvBuilder; |
... | @@ -107,6 +108,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -107,6 +108,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
107 | @Value("${uc.app.appletAppid:wxc57d42de3d351cec}") | 108 | @Value("${uc.app.appletAppid:wxc57d42de3d351cec}") |
108 | private String appletAppid; | 109 | private String appletAppid; |
109 | 110 | ||
111 | |||
112 | @Override | ||
113 | @Transactional(rollbackFor = Exception.class) | ||
114 | public void appLogin(UserApp resources) { | ||
115 | |||
116 | |||
117 | } | ||
118 | |||
110 | /** | 119 | /** |
111 | * 创建大屏账户同时创建会员 | 120 | * 创建大屏账户同时创建会员 |
112 | * | 121 | * |
... | @@ -1036,6 +1045,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1036,6 +1045,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
1036 | return true; | 1045 | return true; |
1037 | } | 1046 | } |
1038 | 1047 | ||
1048 | @Override | ||
1049 | public boolean appBind(BindBean resources) { | ||
1050 | return this.minaBind(resources); | ||
1051 | } | ||
1052 | |||
1039 | /** | 1053 | /** |
1040 | * | 1054 | * |
1041 | * @param resource 会员信息 | 1055 | * @param resource 会员信息 |
... | @@ -1387,6 +1401,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1387,6 +1401,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
1387 | 1401 | ||
1388 | 1402 | ||
1389 | 1403 | ||
1404 | |||
1390 | @AsyncMqSend | 1405 | @AsyncMqSend |
1391 | public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {} | 1406 | public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {} |
1392 | @AsyncMqSend | 1407 | @AsyncMqSend | ... | ... |
... | @@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest { | ... | @@ -39,16 +39,16 @@ public class GeneratorCode extends BaseTest { |
39 | @Rollback(value = false) | 39 | @Rollback(value = false) |
40 | @Transactional(rollbackFor = Exception.class) | 40 | @Transactional(rollbackFor = Exception.class) |
41 | public void generator() { | 41 | public void generator() { |
42 | var dbName = "uc_wechat_share_record"; | 42 | var dbName = "uc_user_app_bind"; |
43 | // 表名称,支持多表 | 43 | // 表名称,支持多表 |
44 | var tableNames = Arrays.asList(dbName); | 44 | var tableNames = Arrays.asList(dbName); |
45 | String[] s = dbName.split("_"); | 45 | String[] s = dbName.split("_"); |
46 | 46 | ||
47 | var pre = s[0]; | 47 | var pre = s[0]; |
48 | var target1 = s[s.length-1]; | 48 | var target1 = s[s.length-1]; |
49 | var preRoute = "com.topdraw.business.module.user.weixin."; | 49 | var preRoute = "com.topdraw.business.module.user.app"; |
50 | StringBuilder builder = new StringBuilder(preRoute); | 50 | StringBuilder builder = new StringBuilder(preRoute); |
51 | builder.append("wechatshare"); | 51 | // builder.append("wechatshare"); |
52 | // builder.append(target); | 52 | // builder.append(target); |
53 | 53 | ||
54 | tableNames.forEach(tableName -> { | 54 | tableNames.forEach(tableName -> { | ... | ... |
-
Please register or sign in to post a comment