Commit ccf3dc70 ccf3dc70b39768f85608eb43c8a076f02e36b5c5 by xianghan

1.优化部分会员信息与会员属性逻辑

1 parent c83b7a48
Showing 101 changed files with 1338 additions and 1735 deletions
1 package com.topdraw.business.module.common.domain; 1 package com.topdraw.business.module.common.domain;
2 2
3 import com.topdraw.business.common.CreateGroup; 3 import com.topdraw.business.module.common.validated.CreateGroup;
4 import com.topdraw.business.common.UpdateGroup; 4 import com.topdraw.business.module.common.validated.UpdateGroup;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
7 7
...@@ -19,10 +19,13 @@ import javax.validation.constraints.NotNull; ...@@ -19,10 +19,13 @@ import javax.validation.constraints.NotNull;
19 */ 19 */
20 @Data 20 @Data
21 @Accessors(chain = true) 21 @Accessors(chain = true)
22 public class DefaultAsyncMqModule { 22 public class AsyncMqModule {
23 23
24 @Transient 24 @Transient
25 @NotNull(message = "memberCode can't be null" , groups = {CreateGroup.class, UpdateGroup.class}) 25 @NotNull(message = "memberCode can't be null" , groups = {CreateGroup.class, UpdateGroup.class})
26 private String memberCode; 26 private String memberCode;
27 27
28 /** 运营商平台账号 */
29 @Transient
30 private String platformAccount;
28 } 31 }
......
1 package com.topdraw.business.common; 1 package com.topdraw.business.module.common.validated;
2 2
3 /** 3 /**
4 * @author : 4 * @author :
......
1 package com.topdraw.business.common; 1 package com.topdraw.business.module.common.validated;
2 2
3 /** 3 /**
4 * @author : 4 * @author :
......
1 package com.topdraw.business.module.member.address.domain; 1 package com.topdraw.business.module.member.address.domain;
2 2
3 import com.topdraw.business.common.CreateGroup; 3 import com.topdraw.business.module.common.domain.AsyncMqModule;
4 import com.topdraw.business.common.UpdateGroup;
5 import lombok.Data; 4 import lombok.Data;
6 import lombok.experimental.Accessors; 5 import lombok.experimental.Accessors;
7 import cn.hutool.core.bean.BeanUtil; 6 import cn.hutool.core.bean.BeanUtil;
8 import cn.hutool.core.bean.copier.CopyOptions; 7 import cn.hutool.core.bean.copier.CopyOptions;
9 import javax.persistence.*; 8 import javax.persistence.*;
10 import javax.validation.constraints.NotNull;
11 9
12 import org.springframework.data.annotation.CreatedDate; 10 import org.springframework.data.annotation.CreatedDate;
13 import org.springframework.data.annotation.LastModifiedDate; 11 import org.springframework.data.annotation.LastModifiedDate;
...@@ -25,7 +23,7 @@ import java.time.LocalDateTime; ...@@ -25,7 +23,7 @@ import java.time.LocalDateTime;
25 @EntityListeners(AuditingEntityListener.class) 23 @EntityListeners(AuditingEntityListener.class)
26 @Accessors(chain = true) 24 @Accessors(chain = true)
27 @Table(name="uc_member_address") 25 @Table(name="uc_member_address")
28 public class MemberAddress implements Serializable { 26 public class MemberAddress extends AsyncMqModule implements Serializable {
29 27
30 /** 主键 */ 28 /** 主键 */
31 @Id 29 @Id
...@@ -37,10 +35,6 @@ public class MemberAddress implements Serializable { ...@@ -37,10 +35,6 @@ public class MemberAddress implements Serializable {
37 @Column(name = "member_id", nullable = false) 35 @Column(name = "member_id", nullable = false)
38 private Long memberId; 36 private Long memberId;
39 37
40 @Transient
41 @NotNull(message = "memberCode can't be null" , groups= {CreateGroup.class})
42 private String memberCode;
43
44 /** 类型 1:家;2:公司;3:学校 */ 38 /** 类型 1:家;2:公司;3:学校 */
45 @Column(name = "type", nullable = false) 39 @Column(name = "type", nullable = false)
46 private Integer type; 40 private Integer type;
......
1 package com.topdraw.business.module.member.address.domain;
2
3 import com.topdraw.business.module.member.domain.Member;
4 import org.apache.commons.lang3.StringUtils;
5
6 import java.util.Objects;
7
8 /**
9 * @author :
10 * @description:
11 * @function :
12 * @date :Created in 2022/3/11 11:08
13 * @version: :
14 * @modified By:
15 * @since : modified in 2022/3/11 11:08
16 */
17 public class MemberAddressBuilder {
18
19 private static final Integer DEFAULT_VALUE_0 = 0;
20 private static final Integer DEFAULT_VALUE_1 = 1;
21
22 public static MemberAddress build(MemberAddress memberAddress, Long memberId,String memberCode){
23 Long id = memberAddress.getId();
24 Integer type = memberAddress.getType();
25 Integer isDefault = memberAddress.getIsDefault();
26 Integer sequence = memberAddress.getSequence();
27 Integer status= memberAddress.getStatus();
28 String contactor = memberAddress.getContactor();
29 String cellphone = memberAddress.getCellphone();
30 String country = memberAddress.getCountry();
31 String province = memberAddress.getProvince();
32 String city = memberAddress.getCity();
33 String district = memberAddress.getDistrict();
34 String address = memberAddress.getAddress();
35 String zipCode = memberAddress.getZipCode();
36 return build(id,memberId,memberCode,type,isDefault,sequence,status,
37 contactor,cellphone,country,province,city,district,address,zipCode);
38 }
39
40 public static MemberAddress build(MemberAddress memberAddress, Member member){
41 Long id = memberAddress.getId();
42 Long memberId = member.getId();
43 String memberCode = member.getCode();
44 Integer type = memberAddress.getType();
45 Integer isDefault = memberAddress.getIsDefault();
46 Integer sequence = memberAddress.getSequence();
47 Integer status= memberAddress.getStatus();
48 String contactor = memberAddress.getContactor();
49 String cellphone = memberAddress.getCellphone();
50 String country = memberAddress.getCountry();
51 String province = memberAddress.getProvince();
52 String city = memberAddress.getCity();
53 String district = memberAddress.getDistrict();
54 String address = memberAddress.getAddress();
55 String zipCode = memberAddress.getZipCode();
56 return build(id,memberId,memberCode,type,isDefault,sequence,status,
57 contactor,cellphone,country,province,city,district,address,zipCode);
58 }
59
60 public static MemberAddress build(MemberAddress memberAddress){
61 Long id = memberAddress.getId();
62 Long memberId = memberAddress.getMemberId();
63 String memberCode = memberAddress.getMemberCode();
64 Integer type = memberAddress.getType();
65 Integer isDefault = memberAddress.getIsDefault();
66 Integer sequence = memberAddress.getSequence();
67 Integer status= memberAddress.getStatus();
68 String contactor = memberAddress.getContactor();
69 String cellphone = memberAddress.getCellphone();
70 String country = memberAddress.getCountry();
71 String province = memberAddress.getProvince();
72 String city = memberAddress.getCity();
73 String district = memberAddress.getDistrict();
74 String address = memberAddress.getAddress();
75 String zipCode = memberAddress.getZipCode();
76 return build(id,memberId,memberCode,type,isDefault,sequence,status,
77 contactor,cellphone,country,province,city,district,address,zipCode);
78 }
79
80
81 public static MemberAddress build(Long id , Long memberId,String memberCode,
82 Integer sequence,Integer type ,Integer isDefault , Integer status,
83 String contactor,String cellphone,
84 String country,String province,String city,
85 String district,String address,String zipCode){
86
87 MemberAddress memberAddress = new MemberAddress();
88 memberAddress.setId(Objects.nonNull(id)?null:id);
89 memberAddress.setMemberId(Objects.nonNull(memberId)?null:memberId);
90 memberAddress.setMemberCode(stringIsNull(memberCode));
91
92 memberAddress.setSequence(Objects.nonNull(sequence)?null:DEFAULT_VALUE_1);
93 memberAddress.setType(Objects.nonNull(type)?null:DEFAULT_VALUE_0);
94 memberAddress.setIsDefault(Objects.nonNull(isDefault)?null:DEFAULT_VALUE_0);
95 memberAddress.setStatus(Objects.nonNull(status)?null:DEFAULT_VALUE_1);
96
97 memberAddress.setContactor(stringIsNull(contactor));
98 memberAddress.setCellphone(stringIsNull(cellphone));
99
100 memberAddress.setCountry(stringIsNull(country));
101 memberAddress.setProvince(stringIsNull(province));
102 memberAddress.setCity(stringIsNull(city));
103 memberAddress.setDistrict(stringIsNull(district));
104 memberAddress.setAddress(stringIsNull(address));
105 memberAddress.setZipCode(stringIsNull(zipCode));
106
107 return memberAddress;
108
109 }
110
111
112 private static String stringIsNull(String s){
113 return StringUtils.isBlank(s)?"":s;
114 }
115
116 private static Object objectIsNull(Object s){
117 return Objects.nonNull(s)?null:s;
118 }
119 }
1 package com.topdraw.business.module.member.address.rest; 1 package com.topdraw.business.module.member.address.rest;
2 2
3 import com.topdraw.aop.log.Log; 3 import com.topdraw.aop.log.Log;
4 import com.topdraw.business.common.CreateGroup; 4 import com.topdraw.business.module.common.validated.CreateGroup;
5 import com.topdraw.business.common.UpdateGroup; 5 import com.topdraw.business.module.common.validated.UpdateGroup;
6 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
7 import com.topdraw.business.module.member.address.domain.MemberAddress; 7 import com.topdraw.business.module.member.address.domain.MemberAddress;
8 import com.topdraw.business.module.member.address.service.MemberAddressService; 8 import com.topdraw.business.module.member.address.service.MemberAddressService;
......
...@@ -2,10 +2,6 @@ package com.topdraw.business.module.member.address.service; ...@@ -2,10 +2,6 @@ package com.topdraw.business.module.member.address.service;
2 2
3 import com.topdraw.business.module.member.address.domain.MemberAddress; 3 import com.topdraw.business.module.member.address.domain.MemberAddress;
4 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; 4 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
5 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7 import java.util.Map;
8 import java.util.List;
9 5
10 /** 6 /**
11 * @author XiangHan 7 * @author XiangHan
...@@ -15,10 +11,10 @@ public interface MemberAddressService { ...@@ -15,10 +11,10 @@ public interface MemberAddressService {
15 11
16 /** 12 /**
17 * 根据ID查询 13 * 根据ID查询
18 * @param id ID 14 * @param resources ID
19 * @return MemberAddressDTO 15 * @return MemberAddressDTO
20 */ 16 */
21 MemberAddressDTO findById(Long id); 17 MemberAddressDTO findById(Long resources);
22 18
23 /** 19 /**
24 * 保存会员地址 20 * 保存会员地址
......
1 package com.topdraw.business.module.member.address.service.dto; 1 package com.topdraw.business.module.member.address.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp;
5 import java.io.Serializable; 4 import java.io.Serializable;
6 import java.time.LocalDateTime; 5 import java.time.LocalDateTime;
7 6
...@@ -13,51 +12,51 @@ import java.time.LocalDateTime; ...@@ -13,51 +12,51 @@ import java.time.LocalDateTime;
13 @Data 12 @Data
14 public class MemberAddressDTO implements Serializable { 13 public class MemberAddressDTO implements Serializable {
15 14
16 // 主键 15 /** 主键 */
17 private Long id; 16 private Long id;
18 17
19 // 会员id 18 /** 会员id */
20 private Long memberId; 19 private Long memberId;
21 20
22 // 类型 1:家;2:公司;3:学校 21 /** 类型 1:家;2:公司;3:学校 */
23 private Integer type; 22 private Integer type;
24 23
25 // 是否默认地址 24 /** 是否默认地址 */
26 private Integer isDefault; 25 private Integer isDefault;
27 26
28 // 显示顺序 27 /** 显示顺序 */
29 private Integer sequence; 28 private Integer sequence;
30 29
31 // 状态 0:不可用;1-可用 30 /** 状态 0:不可用;1-可用 */
32 private Integer status; 31 private Integer status;
33 32
34 // 联系人姓名 33 /** 联系人姓名 */
35 private String contactor; 34 private String contactor;
36 35
37 // 联系人电话 36 /** 联系人电话 */
38 private String cellphone; 37 private String cellphone;
39 38
40 // 国家 39 /** 国家 */
41 private String country; 40 private String country;
42 41
43 // 省份 42 /** 省份 */
44 private String province; 43 private String province;
45 44
46 // 城市 45 /** 城市 */
47 private String city; 46 private String city;
48 47
49 // 区县 48 /** 区县 */
50 private String district; 49 private String district;
51 50
52 // 地址 51 /** 地址 */
53 private String address; 52 private String address;
54 53
55 // 邮编 54 /** 邮编 */
56 private String zipCode; 55 private String zipCode;
57 56
58 // 创建时间 57 /** 创建时间 */
59 private LocalDateTime createTime; 58 private LocalDateTime createTime;
60 59
61 // 更新时间 60 /** 更新时间 */
62 private LocalDateTime updateTime; 61 private LocalDateTime updateTime;
63 } 62 }
......
1 package com.topdraw.business.module.member.address.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 /**
7 * @author XiangHan
8 * @date 2021-10-22
9 */
10 @Data
11 public class MemberAddressQueryCriteria{
12
13 @Query
14 private Long memberId;
15
16 }
...@@ -2,28 +2,24 @@ package com.topdraw.business.module.member.address.service.impl; ...@@ -2,28 +2,24 @@ package com.topdraw.business.module.member.address.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.member.address.domain.MemberAddress; 4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.module.member.address.domain.MemberAddressBuilder;
5 import com.topdraw.business.module.member.service.MemberService; 6 import com.topdraw.business.module.member.service.MemberService;
6 import com.topdraw.business.module.member.service.dto.MemberDTO; 7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.util.RedissonUtil;
7 import com.topdraw.utils.ValidationUtil; 9 import com.topdraw.utils.ValidationUtil;
8 import com.topdraw.business.module.member.address.repository.MemberAddressRepository; 10 import com.topdraw.business.module.member.address.repository.MemberAddressRepository;
9 import com.topdraw.business.module.member.address.service.MemberAddressService; 11 import com.topdraw.business.module.member.address.service.MemberAddressService;
10 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; 12 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
11 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
12 import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper; 13 import com.topdraw.business.module.member.address.service.mapper.MemberAddressMapper;
14 import lombok.extern.slf4j.Slf4j;
15 import org.redisson.api.RLock;
16 import org.redisson.api.RedissonClient;
13 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
15 import org.springframework.transaction.annotation.Propagation; 19 import org.springframework.transaction.annotation.Propagation;
16 import org.springframework.transaction.annotation.Transactional; 20 import org.springframework.transaction.annotation.Transactional;
17 import org.springframework.dao.EmptyResultDataAccessException; 21 import org.springframework.dao.EmptyResultDataAccessException;
18 import org.springframework.data.domain.Page;
19 import org.springframework.data.domain.Pageable;
20 import org.springframework.util.Assert; 22 import org.springframework.util.Assert;
21 import com.topdraw.utils.PageUtil;
22 import com.topdraw.utils.QueryHelp;
23
24 import java.util.List;
25 import java.util.Map;
26 import java.util.Objects;
27 23
28 /** 24 /**
29 * @author XiangHan 25 * @author XiangHan
...@@ -31,53 +27,62 @@ import java.util.Objects; ...@@ -31,53 +27,62 @@ import java.util.Objects;
31 */ 27 */
32 @Service 28 @Service
33 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 29 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
30 @Slf4j
34 public class MemberAddressServiceImpl implements MemberAddressService { 31 public class MemberAddressServiceImpl implements MemberAddressService {
35 32
36 @Autowired 33 @Autowired
37 private MemberAddressRepository MemberAddressRepository; 34 private MemberService memberService;
38 @Autowired 35 @Autowired
39 private MemberAddressMapper MemberAddressMapper; 36 private MemberAddressMapper memberAddressMapper;
40 @Autowired 37 @Autowired
41 private MemberService memberService; 38 private MemberAddressRepository memberAddressRepository;
42 39
40 @Autowired
41 private RedissonClient redissonClient;
42
43 @Override 43 @Override
44 public MemberAddressDTO findById(Long id) { 44 public MemberAddressDTO findById(Long id) {
45 MemberAddress MemberAddress = MemberAddressRepository.findById(id).orElseGet(MemberAddress::new); 45 Assert.notNull(id,"id can't be null");
46 MemberAddress MemberAddress = this.memberAddressRepository.findById(id).orElseGet(MemberAddress::new);
46 ValidationUtil.isNull(MemberAddress.getId(),"MemberAddress","id",id); 47 ValidationUtil.isNull(MemberAddress.getId(),"MemberAddress","id",id);
47 return MemberAddressMapper.toDto(MemberAddress); 48 return this.memberAddressMapper.toDto(MemberAddress);
48 } 49 }
49 50
50 @Override 51 @Override
51 @Transactional(rollbackFor = Exception.class) 52 @Transactional(rollbackFor = Exception.class)
52 @AsyncMqSend() 53 @AsyncMqSend()
53 public void create(MemberAddress resources) { 54 public void create(MemberAddress resources) {
54 Long memberId = resources.getMemberId(); 55 log.info("MemberAddressServiceImpl ==>> create ==>> param ==>> [{}]",resources);
55 MemberDTO memberDTO = this.memberService.findById(memberId); 56 MemberDTO memberDTO = this.checkMember(resources);
56 String code = memberDTO.getCode(); 57 MemberAddress memberAddress = MemberAddressBuilder.build(resources, memberDTO.getId(), memberDTO.getCode());
57 resources.setMemberCode(code); 58 this.memberAddressRepository.save(memberAddress);
58 MemberAddressRepository.save(resources); 59 log.info("MemberAddressServiceImpl ==>> create ==>> result ==>> [{}]",resources);
59 } 60 }
60 61
61 @Override 62 @Override
62 @Transactional(rollbackFor = Exception.class) 63 @Transactional(rollbackFor = Exception.class)
63 @AsyncMqSend() 64 @AsyncMqSend()
64 public void update(MemberAddress resources) { 65 public void update(MemberAddress resources) {
66 log.info("MemberAddressServiceImpl ==>> update ==>> param ==>> [{}]",resources);
67 Assert.notNull(resources.getId(),"id can't be null");
68 RLock rLock = this.redissonClient.getLock("MemberAddress::update::code" + resources.getId());
69 try {
70 RedissonUtil.lock(rLock);
71
72 MemberDTO memberDTO = this.checkMember(resources);
73 resources.setMemberCode(memberDTO.getCode());
65 74
66 Long memberId = resources.getMemberId(); 75 MemberAddress MemberAddress = this.memberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new);
67 Integer sequence = resources.getSequence();
68 Assert.notNull(memberId,"memberId can't be null");
69 Assert.notNull(sequence,"sequence can't be null");
70 MemberDTO memberDTO = this.memberService.findById(memberId);
71 if (Objects.nonNull(memberDTO)) {
72 String code = memberDTO.getCode();
73 Assert.notNull(code,"code can't be null");
74 resources.setMemberCode(code);
75 MemberAddress MemberAddress = MemberAddressRepository.findById(resources.getId()).orElseGet(MemberAddress::new);
76 ValidationUtil.isNull( MemberAddress.getId(),"MemberAddress","id",resources.getId()); 76 ValidationUtil.isNull( MemberAddress.getId(),"MemberAddress","id",resources.getId());
77 MemberAddress.copy(resources); 77 MemberAddress.copy(resources);
78 MemberAddressRepository.save(MemberAddress); 78 this.memberAddressRepository.save(MemberAddress);
79 }
80 79
80 } catch (Exception e) {
81 e.printStackTrace();
82 throw e;
83 } finally {
84 RedissonUtil.unlock(rLock);
85 }
81 } 86 }
82 87
83 @Override 88 @Override
...@@ -85,10 +90,30 @@ public class MemberAddressServiceImpl implements MemberAddressService { ...@@ -85,10 +90,30 @@ public class MemberAddressServiceImpl implements MemberAddressService {
85 @AsyncMqSend() 90 @AsyncMqSend()
86 public void delete(Long id) { 91 public void delete(Long id) {
87 Assert.notNull(id, "The given id must not be null!"); 92 Assert.notNull(id, "The given id must not be null!");
88 MemberAddress MemberAddress = MemberAddressRepository.findById(id).orElseThrow( 93 MemberAddress MemberAddress = this.memberAddressRepository.findById(id).orElseThrow(
89 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberAddress.class, id), 1)); 94 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberAddress.class, id), 1));
90 MemberAddressRepository.delete(MemberAddress); 95 this.memberAddressRepository.delete(MemberAddress);
91 } 96 }
92 97
98 /**
99 * 检查会员
100 * @param memberAddress
101 * @return
102 */
103 private MemberDTO checkMember(MemberAddress memberAddress){
104 Long memberId = memberAddress.getMemberId();
105 String memberCode = memberAddress.getMemberCode();
106 return this.checkMember(memberId,memberCode);
107 }
108
109 /**
110 * 检查会员
111 * @param memberId 会员id
112 * @param memberCode 会员code
113 * @return
114 */
115 private MemberDTO checkMember(Long memberId, String memberCode) {
116 return this.memberService.checkMember(memberId, memberCode);
117 }
93 118
94 } 119 }
......
...@@ -2,7 +2,7 @@ package com.topdraw.business.module.member.domain; ...@@ -2,7 +2,7 @@ package com.topdraw.business.module.member.domain;
2 2
3 import cn.hutool.core.bean.BeanUtil; 3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions; 4 import cn.hutool.core.bean.copier.CopyOptions;
5 import com.topdraw.business.module.member.relatedinfo.domain.UpdateGroup; 5 import com.topdraw.business.module.common.validated.UpdateGroup;
6 import lombok.Data; 6 import lombok.Data;
7 import lombok.experimental.Accessors; 7 import lombok.experimental.Accessors;
8 import org.springframework.data.annotation.CreatedDate; 8 import org.springframework.data.annotation.CreatedDate;
...@@ -37,11 +37,11 @@ public class Member implements Serializable { ...@@ -37,11 +37,11 @@ public class Member implements Serializable {
37 @Id 37 @Id
38 @GeneratedValue(strategy = GenerationType.IDENTITY) 38 @GeneratedValue(strategy = GenerationType.IDENTITY)
39 @Column(name = "id") 39 @Column(name = "id")
40 @NotNull(message = "code can't be null!!",groups = {UpdateGroup.class})
40 private Long id; 41 private Long id;
41 42
42 /** 标识 */ 43 /** 标识 */
43 @Column(name = "code", nullable = false) 44 @Column(name = "code", nullable = false)
44 @NotNull(message = "code can't be null!!",groups = {UpdateGroup.class})
45 private String code; 45 private String code;
46 46
47 /** 类型 1:大屏;2:小屏 */ 47 /** 类型 1:大屏;2:小屏 */
......
1 package com.topdraw.business.module.member.domain;
2
3 public interface MemberConstant {
4
5 // vip等级
6 Integer vip[] = new Integer[]{0,1,2,3,4,5,6,7,8};
7
8 }
1 package com.topdraw.business.module.member.group.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.jpa.domain.support.AuditingEntityListener;
8
9 import javax.persistence.*;
10 import java.io.Serializable;
11
12 /**
13 * @author luerlong
14 * @date 2021-09-27
15 */
16 @Entity
17 @Data
18 @EntityListeners(AuditingEntityListener.class)
19 @Accessors(chain = true)
20 @Table(name="uc_group")
21 public class Group implements Serializable {
22
23 /** ID */
24 @Id
25 @GeneratedValue(strategy = GenerationType.IDENTITY)
26 @Column(name = "id")
27 private Long id;
28
29 /** CODE */
30 @Column(name = "code")
31 private String code;
32
33 /** 名称 */
34 @Column(name = "name")
35 private String name;
36
37 /** 状态 0-下线 1-上线 */
38 @Column(name = "status")
39 private Integer status;
40
41 /** 权限 0-测试分组 1-鉴权通过(白名单) 2-不允许精准(黑名单)3-可以精准(金名单) */
42 @Column(name = "permission_type")
43 private Integer permissionType;
44
45 public void copy(Group source){
46 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
47 }
48 }
...@@ -23,58 +23,58 @@ import java.io.Serializable; ...@@ -23,58 +23,58 @@ import java.io.Serializable;
23 @Table(name="uc_member_group") 23 @Table(name="uc_member_group")
24 public class MemberGroup implements Serializable { 24 public class MemberGroup implements Serializable {
25 25
26 // ID ID 26 /** ID */
27 @Id 27 @Id
28 @GeneratedValue(strategy = GenerationType.IDENTITY) 28 @GeneratedValue(strategy = GenerationType.IDENTITY)
29 @Column(name = "id") 29 @Column(name = "id")
30 private Long id; 30 private Long id;
31 31
32 // 分组ID 32 /** 分组ID */
33 @Column(name = "group_id") 33 @Column(name = "group_id")
34 private Long groupId; 34 private Long groupId;
35 35
36 // 会员ID 36 /** 会员ID */
37 @Column(name = "member_id") 37 @Column(name = "member_id")
38 private Long memberId; 38 private Long memberId;
39 39
40 // 运营商平台账号 40 /** 运营商平台账号 */
41 @Column(name = "platform_account") 41 @Column(name = "platform_account")
42 private String platformAccount; 42 private String platformAccount;
43 43
44 // 手机号 44 /** 手机号 */
45 @Column(name = "cellphone") 45 @Column(name = "cellphone")
46 private String cellphone; 46 private String cellphone;
47 47
48 // 设备 48 /** 设备 */
49 @Column(name = "stb_id") 49 @Column(name = "stb_id")
50 private String stbId; 50 private String stbId;
51 51
52 // 有线MAC地址 52 /** 有线MAC地址 */
53 @Column(name = "eth_mac") 53 @Column(name = "eth_mac")
54 private String ethMac; 54 private String ethMac;
55 55
56 // 无线MAC地址 56 /** 无线MAC地址 */
57 @Column(name = "wifi_mac") 57 @Column(name = "wifi_mac")
58 private String wifiMac; 58 private String wifiMac;
59 59
60 // 描述 60 /** 描述 */
61 @Column(name = "description") 61 @Column(name = "description")
62 private String description; 62 private String description;
63 63
64 // 创建者 64 /** 创建者 */
65 @Column(name = "create_by") 65 @Column(name = "create_by")
66 private String createBy; 66 private String createBy;
67 67
68 // 创建时间 68 /** 创建时间 */
69 @CreatedDate 69 @CreatedDate
70 @Column(name = "create_time") 70 @Column(name = "create_time")
71 private Timestamp createTime; 71 private Timestamp createTime;
72 72
73 // 更新者 73 /** 更新者 */
74 @Column(name = "update_by") 74 @Column(name = "update_by")
75 private String updateBy; 75 private String updateBy;
76 76
77 // 更新时间 77 /** 更新时间 */
78 @LastModifiedDate 78 @LastModifiedDate
79 @Column(name = "update_time") 79 @Column(name = "update_time")
80 private Timestamp updateTime; 80 private Timestamp updateTime;
......
1 package com.topdraw.business.module.member.group.repository;
2
3 import com.topdraw.business.module.member.group.domain.Group;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Query;
7
8 import java.util.List;
9 import java.util.Map;
10 import java.util.Optional;
11
12 /**
13 * @author luerlong
14 * @date 2021-09-27
15 */
16 public interface GroupRepository extends JpaRepository<Group, Long>, JpaSpecificationExecutor<Group> {
17
18 Optional<Group> findFirstByCode(String code);
19
20 List<Group> findByName(String name);
21
22 @Query(value = "select t1.id from uc_group t1 left join uc_user__group t2 on t1.id = t2.group_id where t2.user_id = ?1 and t1.permission_type = ?2 ", nativeQuery = true)
23 List<Map<String, Object>> findByUserIdAndPermissionType(Long userId, Integer type);
24 }
1 package com.topdraw.business.module.member.group.rest;
2
3 import com.topdraw.aop.log.Log;
4 import com.topdraw.common.ResultInfo;
5 import com.topdraw.business.module.member.group.domain.MemberGroup;
6 import com.topdraw.business.module.member.group.service.MemberGroupService;
7 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.validation.annotation.Validated;
10 import org.springframework.web.bind.annotation.*;
11 import io.swagger.annotations.*;
12
13 /**
14 * @author XiangHan
15 * @date 2021-11-17
16 */
17 @Api(tags = "会员分组管理")
18 @RestController
19 @RequestMapping("/ucEngine/api/memberGroup")
20 @CrossOrigin
21 @Slf4j
22 public class MemberGroupController {
23
24 @Autowired
25 private MemberGroupService memberGroupService;
26
27 @Log("新增会员分组")
28 @RequestMapping(value = "/create")
29 @ApiOperation("新增会员分组")
30 public ResultInfo create(@Validated @RequestBody MemberGroup resources) {
31 log.info("memberGroup ==>> create ==>> param ==>> [{}]",resources);
32 this.memberGroupService.create(resources);
33 log.info("memberGroup ==>> create ==>> result ==>> [{}]",resources);
34 return ResultInfo.success();
35 }
36
37 @Log("修改会员分组")
38 @RequestMapping(value = "/update")
39 @ApiOperation("修改会员分组")
40 public ResultInfo update(@Validated @RequestBody MemberGroup resources) {
41 log.info("memberGroup ==>> update ==>> param ==>> [{}]",resources);
42 this.memberGroupService.update(resources);
43 log.info("memberGroup ==>> update ==>> result ==>> [{}]",resources);
44 return ResultInfo.success();
45 }
46
47 @Log("删除会员分组")
48 @RequestMapping(value = "/{id}")
49 @ApiOperation("删除会员分组")
50 public ResultInfo delete(@PathVariable(value = "id") Long resources) {
51 log.info("memberGroup ==>> delete ==>> param ==>> [{}]",resources);
52 this.memberGroupService.delete(resources);
53 log.info("memberGroup ==>> delete ==>> result ==>> [{}]",resources);
54 return ResultInfo.success();
55 }
56
57 }
1 package com.topdraw.business.module.member.group.service;
2
3 import com.topdraw.business.module.member.group.service.dto.GroupDTO;
4
5
6 /**
7 * @author luerlong
8 * @date 2021-09-27
9 */
10 public interface GroupService {
11
12
13 /**
14 * 根据ID查询
15 * @param id ID
16 * @return GroupDTO
17 */
18 GroupDTO findById(Long id);
19
20 /**
21 * Code校验
22 * @param code
23 * @return GroupDTO
24 */
25 GroupDTO getByCode(String code);
26 }
...@@ -25,22 +25,4 @@ public interface MemberGroupService { ...@@ -25,22 +25,4 @@ public interface MemberGroupService {
25 */ 25 */
26 MemberGroupDTO findById(Long id); 26 MemberGroupDTO findById(Long id);
27 27
28 /**
29 * 创建会员分组
30 * @param resources
31 */
32 void create(MemberGroup resources);
33
34 /**
35 * 修改会员分组
36 * @param resources
37 */
38 void update(MemberGroup resources);
39
40 /**
41 * 删除会员分组
42 * @param id
43 */
44 void delete(Long id);
45
46 } 28 }
......
1 package com.topdraw.business.module.member.group.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6
7
8 /**
9 * @author luerlong
10 * @date 2021-09-27
11 */
12 @Data
13 public class GroupDTO implements Serializable {
14
15 /** ID */
16 private Long id;
17
18 /** CODE */
19 private String code;
20
21 /** 名称 */
22 private String name;
23
24 /** 状态 0-下线 1-上线 */
25 private Integer status;
26
27 /** 权限 0-测试分组 1-鉴权通过(白名单) 2-不允许精准(黑名单)3-可以精准(金名单) */
28 private Integer permissionType;
29
30 }
...@@ -3,6 +3,7 @@ package com.topdraw.business.module.member.group.service.dto; ...@@ -3,6 +3,7 @@ package com.topdraw.business.module.member.group.service.dto;
3 import lombok.Data; 3 import lombok.Data;
4 import java.sql.Timestamp; 4 import java.sql.Timestamp;
5 import java.io.Serializable; 5 import java.io.Serializable;
6 import java.util.Set;
6 7
7 8
8 /** 9 /**
...@@ -12,42 +13,43 @@ import java.io.Serializable; ...@@ -12,42 +13,43 @@ import java.io.Serializable;
12 @Data 13 @Data
13 public class MemberGroupDTO implements Serializable { 14 public class MemberGroupDTO implements Serializable {
14 15
15 // ID ID 16 /** ID */
16 private Long id; 17 private Long id;
17 18
18 // 分组ID 19 /** 分组ID */
19 private Long groupId; 20 private Long groupId;
20 21
21 // 会员ID 22 /** 会员ID */
22 private Long memberId; 23 private Long memberId;
23 24
24 // 运营商平台账号 25 /** 运营商平台账号 */
25 private String platformAccount; 26 private String platformAccount;
26 27
27 // 手机号 28 /** 手机号 */
28 private String cellphone; 29 private String cellphone;
29 30
30 // 设备 31 /** 设备 */
31 private String stbId; 32 private String stbId;
32 33
33 // 有线MAC地址 34 /** 有线MAC地址 */
34 private String ethMac; 35 private String ethMac;
35 36
36 // 无线MAC地址 37 /** 无线MAC地址 */
37 private String wifiMac; 38 private String wifiMac;
38 39
39 // 描述 40 /** 描述 */
40 private String description; 41 private String description;
41 42
42 // 创建者 43 /** 创建者 */
43 private String createBy; 44 private String createBy;
44 45
45 // 创建时间 46 /** 创建时间 */
46 private Timestamp createTime; 47 private Timestamp createTime;
47 48
48 // 更新者 49 /** 更新者 */
49 private String updateBy; 50 private String updateBy;
50 51
51 // 更新时间 52 /** 更新时间 */
52 private Timestamp updateTime; 53 private Timestamp updateTime;
54
53 } 55 }
......
1 package com.topdraw.business.module.member.group.service.dto;
2
3 import lombok.Data;
4 import com.topdraw.annotation.Query;
5
6 /**
7 * @author XiangHan
8 * @date 2021-11-17
9 */
10 @Data
11 public class MemberGroupQueryCriteria{
12
13 @Query(type = Query.Type.EQUAL)
14 private Long memberId;
15 }
1 package com.topdraw.business.module.member.group.service.impl;
2
3 import com.topdraw.business.module.member.group.domain.Group;
4 import com.topdraw.business.module.member.group.repository.GroupRepository;
5 import com.topdraw.business.module.member.group.service.GroupService;
6 import com.topdraw.business.module.member.group.service.dto.GroupDTO;
7 import com.topdraw.business.module.member.group.service.mapper.GroupMapper;
8 import com.topdraw.utils.*;
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
14 /**
15 * @author luerlong
16 * @date 2021-09-27
17 */
18 @Service
19 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
20 public class GroupServiceImpl implements GroupService {
21
22 @Autowired
23 private GroupRepository groupRepository;
24
25 @Autowired
26 private GroupMapper groupMapper;
27
28 @Override
29 public GroupDTO findById(Long id) {
30 Group group = groupRepository.findById(id).orElseGet(Group::new);
31 ValidationUtil.isNull(group.getId(),"Group","id",id);
32 return groupMapper.toDto(group);
33 }
34
35 @Override
36 public GroupDTO getByCode(String code) {
37 return StringUtils.isNotEmpty(code) ? groupMapper.toDto(groupRepository.findFirstByCode(code).orElseGet(Group::new))
38 : new GroupDTO();
39 }
40 }
...@@ -40,29 +40,4 @@ public class MemberGroupServiceImpl implements MemberGroupService { ...@@ -40,29 +40,4 @@ public class MemberGroupServiceImpl implements MemberGroupService {
40 return this.memberGroupMapper.toDto(memberGroup); 40 return this.memberGroupMapper.toDto(memberGroup);
41 } 41 }
42 42
43 @Override
44 @Transactional(rollbackFor = Exception.class)
45 public void create(MemberGroup resources) {
46 this.memberGroupRepository.save(resources);
47 }
48
49 @Override
50 @Transactional(rollbackFor = Exception.class)
51 public void update(MemberGroup resources) {
52 MemberGroup memberGroup = this.memberGroupRepository.findById(resources.getId()).orElseGet(MemberGroup::new);
53 ValidationUtil.isNull(memberGroup.getId(),"MemberGroup","id",resources.getId());
54 memberGroup.copy(resources);
55 this.memberGroupRepository.save(memberGroup);
56 }
57
58 @Override
59 @Transactional(rollbackFor = Exception.class)
60 public void delete(Long id) {
61 Assert.notNull(id, "The given id must not be null!");
62 MemberGroup MemberGroup = this.memberGroupRepository.findById(id).orElseThrow(
63 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberGroup.class, id), 1));
64 this.memberGroupRepository.delete(MemberGroup);
65 }
66
67
68 } 43 }
......
1 package com.topdraw.business.module.weixin.service.mapper; 1 package com.topdraw.business.module.member.group.service.mapper;
2 2
3 import com.topdraw.base.BaseMapper; 3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate; 4 import com.topdraw.business.module.member.group.domain.Group;
5 import com.topdraw.business.module.weixin.service.dto.WeixinMessageTemplateDTO; 5 import com.topdraw.business.module.member.group.service.dto.GroupDTO;
6 import org.mapstruct.Mapper; 6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy; 7 import org.mapstruct.ReportingPolicy;
8 8
9 /** 9 /**
10 * @author pengmengqing 10 * @author luerlong
11 * @date 2021-01-28 11 * @date 2021-09-27
12 */ 12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) 13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface WeixinMessageTemplateMapper extends BaseMapper<WeixinMessageTemplateDTO, WeixinMessageTemplate> { 14 public interface GroupMapper extends BaseMapper<GroupDTO, Group> {
15 15
16 } 16 }
......
1 package com.topdraw.business.module.member.level.domain; 1 package com.topdraw.business.module.member.level.domain;
2 2
3 import com.topdraw.business.common.CreateGroup; 3 import com.topdraw.business.module.common.validated.CreateGroup;
4 import com.topdraw.business.common.UpdateGroup; 4 import com.topdraw.business.module.common.validated.UpdateGroup;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
7 import cn.hutool.core.bean.BeanUtil; 7 import cn.hutool.core.bean.BeanUtil;
......
1 package com.topdraw.business.module.member.level.rest;
2
3 import com.topdraw.aop.log.Log;
4 import com.topdraw.business.common.CreateGroup;
5 import com.topdraw.business.common.UpdateGroup;
6 import com.topdraw.business.module.member.level.domain.MemberLevel;
7 import com.topdraw.common.ResultInfo;
8 import com.topdraw.business.module.member.level.service.MemberLevelService;
9 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.validation.annotation.Validated;
12 import org.springframework.web.bind.annotation.*;
13 import io.swagger.annotations.*;
14
15 /**
16 * @author XiangHan
17 * @date 2021-10-22
18 */
19 @Api(tags = "等级管理")
20 @RestController
21 @RequestMapping("/ucEngine/api/memberLevel")
22 @CrossOrigin
23 @Slf4j
24 public class MemberLevelController {
25
26 @Autowired
27 private MemberLevelService memberLevelService;
28
29 @Log("新增会员等级")
30 @RequestMapping(value = "/create")
31 @ApiOperation("新增会员等级")
32 public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberLevel resources) {
33 log.info("memberLevel ==>> update ==>> param ==>> [{}]",resources);
34 this.memberLevelService.update(resources);
35 log.info("memberLevel ==>> update ==>> result ==>> [{}]",resources);
36 return ResultInfo.success();
37 }
38
39 @Log("修改等级")
40 @RequestMapping(value = "/update")
41 @ApiOperation("修改等级")
42 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberLevel resources) {
43 log.info("memberLevel ==>> update ==>> param ==>> [{}]",resources);
44 this.memberLevelService.update(resources);
45 log.info("memberLevel ==>> update ==>> result ==>> [{}]",resources);
46 return ResultInfo.success();
47 }
48
49 @Log("删除等级")
50 @DeleteMapping(value = "/delete/{id}")
51 @ApiOperation("删除等级")
52 public ResultInfo delete(@PathVariable Long resources) {
53 log.info("memberLevel ==>> delete ==>> param ==>> [{}]",resources);
54 this.memberLevelService.delete(resources);
55 log.info("memberLevel ==>> delete ==>> result ==>> [{}]",resources);
56 return ResultInfo.success();
57 }
58 }
1 package com.topdraw.business.module.member.level.service; 1 package com.topdraw.business.module.member.level.service;
2 2
3 import com.topdraw.business.module.member.level.domain.MemberLevel;
4 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; 3 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
5 4
6 import java.util.List; 5 import java.util.List;
...@@ -10,6 +9,7 @@ import java.util.List; ...@@ -10,6 +9,7 @@ import java.util.List;
10 * @date 2021-10-22 9 * @date 2021-10-22
11 */ 10 */
12 public interface MemberLevelService { 11 public interface MemberLevelService {
12
13 /** 13 /**
14 * 根据ID查询 14 * 根据ID查询
15 * @param id ID 15 * @param id ID
...@@ -18,12 +18,6 @@ public interface MemberLevelService { ...@@ -18,12 +18,6 @@ public interface MemberLevelService {
18 MemberLevelDTO findById(Long id); 18 MemberLevelDTO findById(Long id);
19 19
20 /** 20 /**
21 *
22 * @param resources
23 */
24 void update(MemberLevel resources);
25
26 /**
27 * Code校验 21 * Code校验
28 * @param code 22 * @param code
29 * @return MemberLevelDTO 23 * @return MemberLevelDTO
...@@ -31,13 +25,12 @@ public interface MemberLevelService { ...@@ -31,13 +25,12 @@ public interface MemberLevelService {
31 MemberLevelDTO getByCode(String code); 25 MemberLevelDTO getByCode(String code);
32 26
33 /** 27 /**
34 * 28 * 通过等级和状态检索
35 * @param i 29 * @param i
36 * @param status 30 * @param status
37 * @return 31 * @return
38 */ 32 */
39 List<MemberLevelDTO> findLevelAndStatus(Integer i, Integer status); 33 List<MemberLevelDTO> findLevelAndStatus(Integer i, Integer status);
40 34
41 void delete(Long resources);
42 35
43 } 36 }
......
...@@ -12,36 +12,36 @@ import java.io.Serializable; ...@@ -12,36 +12,36 @@ import java.io.Serializable;
12 @Data 12 @Data
13 public class MemberLevelDTO implements Serializable { 13 public class MemberLevelDTO implements Serializable {
14 14
15 // 主键 15 /** 主键 */
16 private Long id; 16 private Long id;
17 17
18 // 标识 18 /** 标识 */
19 private String code; 19 private String code;
20 20
21 // 名称 21 /** 名称 */
22 private String name; 22 private String name;
23 23
24 // 状态 0:未启用;1:启用 24 /** 状态 0:未启用;1:启用 */
25 private Integer status; 25 private Integer status;
26 26
27 // 对应成长值 27 /** 对应成长值 */
28 private Long expValue; 28 private Long expValue;
29 29
30 // 等级(不可重复,数字越大等级越高) 30 /** 等级(不可重复,数字越大等级越高) */
31 private Integer level; 31 private Integer level;
32 32
33 // 会员徽标 33 /** 会员徽标 */
34 private String iconUrl; 34 private String iconUrl;
35 35
36 // 描述 36 /** 描述 */
37 private String description; 37 private String description;
38 38
39 // 对应任务id,通过此字段可获得该等级所对应的权益 39 /** 对应任务id,通过此字段可获得该等级所对应的权益 */
40 private Long taskId; 40 private Long taskId;
41 41
42 // 创建时间 42 /** 创建时间 */
43 private Timestamp createTime; 43 private Timestamp createTime;
44 44
45 // 更新时间 45 /** 更新时间 */
46 private Timestamp updateTime; 46 private Timestamp updateTime;
47 } 47 }
......
1 package com.topdraw.business.module.member.level.service.dto;
2
3 import lombok.Data;
4
5 /**
6 * @author XiangHan
7 * @date 2021-10-22
8 */
9 @Data
10 public class MemberLevelQueryCriteria{
11 }
1 package com.topdraw.business.module.member.level.service.impl; 1 package com.topdraw.business.module.member.level.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.member.level.domain.MemberLevel; 3 import com.topdraw.business.module.member.level.domain.MemberLevel;
5 import com.topdraw.utils.ValidationUtil; 4 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.module.member.level.repository.MemberLevelRepository; 5 import com.topdraw.business.module.member.level.repository.MemberLevelRepository;
7 import com.topdraw.business.module.member.level.service.MemberLevelService; 6 import com.topdraw.business.module.member.level.service.MemberLevelService;
8 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; 7 import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO;
9 import com.topdraw.business.module.member.level.service.dto.MemberLevelQueryCriteria;
10 import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper; 8 import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 11 import org.springframework.transaction.annotation.Propagation;
14 import org.springframework.transaction.annotation.Transactional; 12 import org.springframework.transaction.annotation.Transactional;
15 import org.springframework.dao.EmptyResultDataAccessException;
16 import org.springframework.data.domain.Page;
17 import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp;
21 import com.topdraw.utils.StringUtils; 13 import com.topdraw.utils.StringUtils;
22 14
23 import java.util.List; 15 import java.util.List;
24 import java.util.Map;
25 16
26 /** 17 /**
27 * @author XiangHan 18 * @author XiangHan
...@@ -32,41 +23,27 @@ import java.util.Map; ...@@ -32,41 +23,27 @@ import java.util.Map;
32 public class MemberLevelServiceImpl implements MemberLevelService { 23 public class MemberLevelServiceImpl implements MemberLevelService {
33 24
34 @Autowired 25 @Autowired
35 private MemberLevelRepository MemberLevelRepository; 26 private MemberLevelRepository memberLevelRepository;
36 27
37 @Autowired 28 @Autowired
38 private MemberLevelMapper MemberLevelMapper; 29 private MemberLevelMapper memberLevelMapper;
39 30
40 @Override 31 @Override
41 public MemberLevelDTO findById(Long id) { 32 public MemberLevelDTO findById(Long id) {
42 MemberLevel MemberLevel = MemberLevelRepository.findById(id).orElseGet(MemberLevel::new); 33 MemberLevel MemberLevel = this.memberLevelRepository.findById(id).orElseGet(MemberLevel::new);
43 ValidationUtil.isNull(MemberLevel.getId(),"MemberLevel","id",id); 34 ValidationUtil.isNull(MemberLevel.getId(),"MemberLevel","id",id);
44 return MemberLevelMapper.toDto(MemberLevel); 35 return this.memberLevelMapper.toDto(MemberLevel);
45 }
46
47 @Override
48 @Transactional(rollbackFor = Exception.class)
49 @AsyncMqSend()
50 public void update(MemberLevel resources) {
51 MemberLevel MemberLevel = MemberLevelRepository.findById(resources.getId()).orElseGet(MemberLevel::new);
52 ValidationUtil.isNull( MemberLevel.getId(),"MemberLevel","id",resources.getId());
53 MemberLevel.copy(resources);
54 MemberLevelRepository.save(MemberLevel);
55 } 36 }
56 37
57 @Override 38 @Override
58 public MemberLevelDTO getByCode(String code) { 39 public MemberLevelDTO getByCode(String code) {
59 return StringUtils.isNotEmpty(code) ? MemberLevelMapper.toDto(MemberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new)) 40 return StringUtils.isNotEmpty(code) ? this.memberLevelMapper.toDto(this.memberLevelRepository.findFirstByCode(code).orElseGet(MemberLevel::new))
60 : new MemberLevelDTO(); 41 : new MemberLevelDTO();
61 } 42 }
62 43
63 @Override 44 @Override
64 public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { 45 public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) {
65 return MemberLevelMapper.toDto(MemberLevelRepository.findByLevelAndStatus(level,status)); 46 return this.memberLevelMapper.toDto(this.memberLevelRepository.findByLevelAndStatus(level,status));
66 } 47 }
67 48
68 @Override
69 public void delete(Long resources) {
70 MemberLevelRepository.deleteById(resources);
71 }
72 } 49 }
......
1 package com.topdraw.business.module.member.profile.domain; 1 package com.topdraw.business.module.member.profile.domain;
2 2
3 import com.topdraw.business.common.CreateGroup; 3 import com.topdraw.business.module.common.validated.CreateGroup;
4 import com.topdraw.business.common.UpdateGroup; 4 import com.topdraw.business.module.common.validated.UpdateGroup;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
7 import cn.hutool.core.bean.BeanUtil; 7 import cn.hutool.core.bean.BeanUtil;
...@@ -15,7 +15,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; ...@@ -15,7 +15,6 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
15 import java.sql.Timestamp; 15 import java.sql.Timestamp;
16 16
17 import java.io.Serializable; 17 import java.io.Serializable;
18 import java.time.LocalDate;
19 18
20 /** 19 /**
21 * @author XiangHan 20 * @author XiangHan
......
...@@ -5,7 +5,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -5,7 +5,7 @@ import org.apache.commons.lang3.StringUtils;
5 5
6 import java.util.Objects; 6 import java.util.Objects;
7 7
8 public class MemberProfileBuild { 8 public class MemberProfileBuilder {
9 9
10 public static MemberProfile build(Member member){ 10 public static MemberProfile build(Member member){
11 MemberProfile memberProfile = build(member.getId(),member.getNickname(),member.getGender(),"","","","","","", 11 MemberProfile memberProfile = build(member.getId(),member.getNickname(),member.getGender(),"","","","","","",
...@@ -61,10 +61,6 @@ public class MemberProfileBuild { ...@@ -61,10 +61,6 @@ public class MemberProfileBuild {
61 return StringUtils.isBlank(s)?"":s; 61 return StringUtils.isBlank(s)?"":s;
62 } 62 }
63 63
64 private static Object objectIsNull(Object s){
65 return Objects.nonNull(s)?null:s;
66 }
67
68 public static MemberProfile build(MemberProfile resources) { 64 public static MemberProfile build(MemberProfile resources) {
69 if (resources.getMemberId() == null) 65 if (resources.getMemberId() == null)
70 throw new NullPointerException("memberId is null"); 66 throw new NullPointerException("memberId is null");
......
...@@ -3,11 +3,10 @@ package com.topdraw.business.module.member.profile.service.impl; ...@@ -3,11 +3,10 @@ package com.topdraw.business.module.member.profile.service.impl;
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.module.member.profile.domain.MemberProfile; 5 import com.topdraw.business.module.member.profile.domain.MemberProfile;
6 import com.topdraw.business.module.member.profile.domain.MemberProfileBuild; 6 import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder;
7 import com.topdraw.business.module.member.repository.MemberRepository;
8 import com.topdraw.business.module.member.service.MemberService; 7 import com.topdraw.business.module.member.service.MemberService;
9 import com.topdraw.business.module.member.service.dto.MemberDTO; 8 import com.topdraw.business.module.member.service.dto.MemberDTO;
10 import com.topdraw.exception.BadRequestException; 9 import com.topdraw.util.Base64Util;
11 import com.topdraw.util.RedissonUtil; 10 import com.topdraw.util.RedissonUtil;
12 import com.topdraw.utils.StringUtils; 11 import com.topdraw.utils.StringUtils;
13 import com.topdraw.utils.ValidationUtil; 12 import com.topdraw.utils.ValidationUtil;
...@@ -26,8 +25,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -26,8 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
26 import org.springframework.dao.EmptyResultDataAccessException; 25 import org.springframework.dao.EmptyResultDataAccessException;
27 import org.springframework.util.Assert; 26 import org.springframework.util.Assert;
28 27
29 import java.nio.charset.StandardCharsets;
30 import java.util.*;
31 28
32 /** 29 /**
33 * @author XiangHan 30 * @author XiangHan
...@@ -75,14 +72,12 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -75,14 +72,12 @@ public class MemberProfileServiceImpl implements MemberProfileService {
75 @Transactional(rollbackFor = Exception.class) 72 @Transactional(rollbackFor = Exception.class)
76 @AsyncMqSend() 73 @AsyncMqSend()
77 public MemberProfile create(MemberProfile resources) { 74 public MemberProfile create(MemberProfile resources) {
78
79 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); 75 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
80 Long memberId = resources.getMemberId();
81 Assert.notNull(memberId,"memberId can't be null !!");
82 76
83 MemberDTO memberDTO = this.memberService.findById(memberId); 77 // 检查会员
84 if (Objects.nonNull(memberDTO.getCode())) 78 this.checkMember(resources);
85 this.memberProfileRepository.save(resources); 79
80 this.memberProfileRepository.save(resources);
86 81
87 return resources; 82 return resources;
88 } 83 }
...@@ -90,62 +85,53 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -90,62 +85,53 @@ public class MemberProfileServiceImpl implements MemberProfileService {
90 @Override 85 @Override
91 @Transactional(rollbackFor = Exception.class) 86 @Transactional(rollbackFor = Exception.class)
92 public MemberProfile createDefault(MemberProfile resources) { 87 public MemberProfile createDefault(MemberProfile resources) {
93 MemberProfile memberProfile = MemberProfileBuild.build(); 88 MemberProfile memberProfile = MemberProfileBuilder.build();
94 return this.create(memberProfile); 89 return this.create(memberProfile);
95 } 90 }
96 91
97 @Override 92 @Override
98 @Transactional(rollbackFor = Exception.class) 93 @Transactional(rollbackFor = Exception.class)
99 public MemberProfile createDefault(Member resources) { 94 public MemberProfile createDefault(Member resources) {
100 MemberProfile memberProfile = MemberProfileBuild.build(resources); 95 MemberProfile memberProfile = MemberProfileBuilder.build(resources);
101 return this.create(memberProfile); 96 return this.create(memberProfile);
102 } 97 }
103 98
104 @Override 99 @Override
105 public MemberProfile createDefaultByMemberId(Long resources) { 100 public MemberProfile createDefaultByMemberId(Long resources) {
106 MemberProfile memberProfile = MemberProfileBuild.build(resources); 101 MemberProfile memberProfile = MemberProfileBuilder.build(resources);
107 return this.create(memberProfile); 102 return this.create(memberProfile);
108 } 103 }
109 104
105 private MemberDTO checkMember(MemberProfile resources){
106 Long memberId = resources.getMemberId();
107 String memberCode = resources.getMemberCode();
108
109 return this.memberService.checkMember(memberId,memberCode);
110 }
111
110 @Override 112 @Override
111 @Transactional(rollbackFor = Exception.class) 113 @Transactional(rollbackFor = Exception.class)
112 @AsyncMqSend() 114 @AsyncMqSend()
113 public void update(MemberProfile resources) { 115 public void update(MemberProfile resources) {
114 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
115
116 Long memberId = resources.getMemberId();
117 String memberCode = resources.getMemberCode();
118 if (Objects.isNull(memberId) && StringUtils.isBlank(memberCode))
119 throw new BadRequestException("memberId Or memberCode both null !!");
120
121 String realName = resources.getRealname();
122 if (StringUtils.isNotBlank(realName)) {
123 resources.setRealname(new String(Base64.getEncoder().encode(realName.getBytes(StandardCharsets.UTF_8))));
124 }
125 116
117 log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
126 RLock rLock = this.redissonClient.getLock("memberProfile::update::id" + resources.getId()); 118 RLock rLock = this.redissonClient.getLock("memberProfile::update::id" + resources.getId());
127 try { 119 try {
128 RedissonUtil.lock(rLock); 120 RedissonUtil.lock(rLock);
129 121
130 this.memberService.findByIdOrCode(memberId, memberCode); 122 // 检查会员是否存在
131 123 this.checkMember(resources);
132 MemberProfileDTO memberProfile = this.findByMemberId(memberId); 124 // 真实姓名(加密)
133 if (Objects.nonNull(memberProfile)) { 125 String realName = resources.getRealname();
134 resources.setId(memberProfile.getId()); 126 if (StringUtils.isNotBlank(realName)) {
135 127 resources.setRealname(Base64Util.encode(realName));
136 MemberProfile memberProfile1 = new MemberProfile();
137 BeanUtils.copyProperties(memberProfile,memberProfile1);
138 this.memberProfileRepository.save(memberProfile1);
139
140 // 同步会员信息
141 this.synchronizedMemberData(resources);
142
143 } else {
144 resources.setId(null);
145 MemberProfile memberProfile1 = MemberProfileBuild.build(resources);
146 this.create(memberProfile1);
147 } 128 }
148 129
130 MemberProfile memberProfile = new MemberProfile();
131 BeanUtils.copyProperties(resources,memberProfile);
132 this.memberProfileRepository.save(memberProfile);
133 // 同步会员信息
134 this.synchronizedMemberData(resources);
149 } catch (Exception e) { 135 } catch (Exception e) {
150 e.printStackTrace(); 136 e.printStackTrace();
151 throw e; 137 throw e;
...@@ -169,22 +155,20 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -169,22 +155,20 @@ public class MemberProfileServiceImpl implements MemberProfileService {
169 @Transactional(rollbackFor = Exception.class) 155 @Transactional(rollbackFor = Exception.class)
170 public void updateMemberProfileAndMember(MemberProfile resources) { 156 public void updateMemberProfileAndMember(MemberProfile resources) {
171 log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources); 157 log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources);
172
173 this.update(resources); 158 this.update(resources);
174
175 } 159 }
176 160
177 161 /**
162 * 同步会员信息
163 * @param nickName
164 * @param gender
165 * @param birthday
166 * @param avatarUrl
167 * @param member
168 */
178 private void synchronizedMemberData(String nickName , Integer gender , String birthday, 169 private void synchronizedMemberData(String nickName , Integer gender , String birthday,
179 String avatarUrl,Member member) { 170 String avatarUrl,Member member) {
180 MemberProfile memberProfile = new MemberProfile(); 171 this.synchronizedMemberData(nickName,gender,birthday,avatarUrl,member.getId(),member.getCode());
181 memberProfile.setMemberId(member.getId());
182 memberProfile.setMemberCode(member.getCode());
183 memberProfile.setRealname(nickName);
184 memberProfile.setGender(gender);
185 memberProfile.setBirthday(birthday);
186 memberProfile.setAvatarUrl(avatarUrl);
187 this.synchronizedMemberData(memberProfile);
188 } 172 }
189 173
190 private void synchronizedMemberData(String nickName , Integer gender , String birthday, 174 private void synchronizedMemberData(String nickName , Integer gender , String birthday,
...@@ -201,17 +185,17 @@ public class MemberProfileServiceImpl implements MemberProfileService { ...@@ -201,17 +185,17 @@ public class MemberProfileServiceImpl implements MemberProfileService {
201 185
202 private void synchronizedMemberData(MemberProfile resources) { 186 private void synchronizedMemberData(MemberProfile resources) {
203 187
204 MemberDTO memberDTO = this.memberService.findByIdOrCode(resources.getMemberId(),resources.getMemberCode()); 188 log.info("updateMemberProfileAndMember ==>> resources ==>> [{}]",resources);
205 189
206 Member member = new Member(); 190 Member member = new Member();
207 BeanUtils.copyProperties(memberDTO,member); 191 member.setId(resources.getMemberId());
192 member.setCode(resources.getMemberCode());
208 member.setNickname(resources.getRealname()); 193 member.setNickname(resources.getRealname());
209 member.setGender(resources.getGender()); 194 member.setGender(resources.getGender());
210 member.setBirthday(resources.getBirthday()); 195 member.setBirthday(resources.getBirthday());
211 member.setAvatarUrl(resources.getAvatarUrl()); 196 member.setAvatarUrl(resources.getAvatarUrl());
212 197
213 log.info("updateMemberProfileAndMember ==>> member ==>> [{}]",member); 198 this.memberService.update(member);
214 memberService.update(member);
215 } 199 }
216 200
217 } 201 }
......
1 package com.topdraw.business.module.member.relatedinfo.domain; 1 package com.topdraw.business.module.member.relatedinfo.domain;
2 2
3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; 3 import com.topdraw.business.module.common.validated.UpdateGroup;
4 import com.topdraw.business.module.common.domain.AsyncMqModule;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
6 import cn.hutool.core.bean.BeanUtil; 7 import cn.hutool.core.bean.BeanUtil;
...@@ -25,53 +26,53 @@ import java.time.LocalDate; ...@@ -25,53 +26,53 @@ import java.time.LocalDate;
25 @EntityListeners(AuditingEntityListener.class) 26 @EntityListeners(AuditingEntityListener.class)
26 @Accessors(chain = true) 27 @Accessors(chain = true)
27 @Table(name="uc_member_related_info") 28 @Table(name="uc_member_related_info")
28 public class MemberRelatedInfo extends DefaultAsyncMqModule implements Serializable { 29 public class MemberRelatedInfo extends AsyncMqModule implements Serializable {
29 30
30 // ID 31 /** ID */
31 @Id 32 @Id
32 @GeneratedValue(strategy = GenerationType.IDENTITY) 33 @GeneratedValue(strategy = GenerationType.IDENTITY)
33 @Column(name = "id") 34 @Column(name = "id")
34 @NotNull(groups = {UpdateGroup.class}) 35 @NotNull(message = "id can't be null" , groups = {UpdateGroup.class})
35 private Long id; 36 private Long id;
36 37
37 // 会员id 38 /** 会员id */
38 @Column(name = "member_id", nullable = false) 39 @Column(name = "member_id", nullable = false)
39 private Long memberId; 40 private Long memberId;
40 41
41 // 人物关系 0:子女;1:父母 42 /** 人物关系 0:子女;1:父母 */
42 @Column(name = "type") 43 @Column(name = "type")
43 private Integer type; 44 private Integer type;
44 45
45 // 手机号 46 /** 手机号 */
46 @Column(name = "cellphone") 47 @Column(name = "cellphone")
47 private String cellphone; 48 private String cellphone;
48 49
49 // 身份证号 50 /** 身份证号 */
50 @Column(name = "id_card") 51 @Column(name = "id_card")
51 private String idCard; 52 private String idCard;
52 53
53 // 姓名 54 /** 姓名 */
54 @Column(name = "name") 55 @Column(name = "name")
55 private String name; 56 private String name;
56 57
57 // 性别 0:女;1:男;-1:未知 58 /** 性别 0:女;1:男;-1:未知 */
58 @Column(name = "sex") 59 @Column(name = "sex")
59 private Integer sex; 60 private Integer sex;
60 61
61 // 生日 62 /** 生日 */
62 @Column(name = "birthday") 63 @Column(name = "birthday")
63 private LocalDate birthday; 64 private LocalDate birthday;
64 65
65 // 头像地址 66 /** 头像地址 */
66 @Column(name = "avatar_url") 67 @Column(name = "avatar_url")
67 private String avatarUrl; 68 private String avatarUrl;
68 69
69 // 创建时间 70 /** 创建时间 */
70 @CreatedDate 71 @CreatedDate
71 @Column(name = "create_time") 72 @Column(name = "create_time")
72 private Timestamp createTime; 73 private Timestamp createTime;
73 74
74 // 更新时间 75 /** 更新时间 */
75 @LastModifiedDate 76 @LastModifiedDate
76 @Column(name = "update_time") 77 @Column(name = "update_time")
77 private Timestamp updateTime; 78 private Timestamp updateTime;
......
1 package com.topdraw.business.module.member.relatedinfo.domain;
2
3 import com.topdraw.business.module.member.domain.Member;
4 import org.apache.commons.lang3.StringUtils;
5
6 import java.time.LocalDate;
7 import java.util.Objects;
8
9 /**
10 * @author :
11 * @description:
12 * @function :
13 * @date :Created in 2022/3/11 13:56
14 * @version: :
15 * @modified By:
16 * @since : modified in 2022/3/11 13:56
17 */
18 public class MemberRelatedInfoBuilder {
19
20 private static final Integer DEFAULT_VALUE_ = -1;
21 private static final Integer DEFAULT_VALUE_0 = 0;
22
23 public static MemberRelatedInfo build(MemberRelatedInfo memberRelatedInfo){
24 return build(memberRelatedInfo.getId(),memberRelatedInfo.getMemberCode(),memberRelatedInfo.getId(),memberRelatedInfo.getName(),memberRelatedInfo.getSex(),
25 memberRelatedInfo.getCellphone(),memberRelatedInfo.getIdCard(),memberRelatedInfo.getBirthday(),memberRelatedInfo.getAvatarUrl(),memberRelatedInfo.getType());
26 }
27
28 public static MemberRelatedInfo build(Member member , MemberRelatedInfo memberRelatedInfo){
29 return build(member.getId(),member.getCode(),memberRelatedInfo.getId(),memberRelatedInfo.getName(),memberRelatedInfo.getSex(),
30 memberRelatedInfo.getCellphone(),memberRelatedInfo.getIdCard(),memberRelatedInfo.getBirthday(),memberRelatedInfo.getAvatarUrl(),memberRelatedInfo.getType());
31 }
32
33 public static MemberRelatedInfo build(Long memberId , String memberCode , Long id , String name , Integer sex ,
34 String cellphone , String idCard, LocalDate birthday , String avatarUrl , Integer type){
35 MemberRelatedInfo memberRelatedInfo = new MemberRelatedInfo();
36 memberRelatedInfo.setMemberId(memberId);
37 memberRelatedInfo.setMemberCode(memberCode);
38
39 memberRelatedInfo.setId(id);
40 memberRelatedInfo.setName(stringIsNull(name));
41 memberRelatedInfo.setSex(Objects.isNull(sex)?DEFAULT_VALUE_:sex);
42 memberRelatedInfo.setCellphone(stringIsNull(cellphone));
43 memberRelatedInfo.setIdCard(StringUtils.isBlank(idCard)?"000000000000000000":idCard);
44
45 memberRelatedInfo.setBirthday(Objects.isNull(birthday)? LocalDate.of(1990,01,01):birthday);
46 memberRelatedInfo.setAvatarUrl(stringIsNull(avatarUrl));
47
48 memberRelatedInfo.setType(Objects.isNull(type)?DEFAULT_VALUE_0:type);
49 return memberRelatedInfo;
50 }
51
52 private static String stringIsNull(String s){
53 return StringUtils.isBlank(s)?"":s;
54 }
55
56 }
1 package com.topdraw.business.module.member.relatedinfo.domain;
2
3 public interface UpdateGroup {
4 }
...@@ -4,10 +4,17 @@ import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; ...@@ -4,10 +4,17 @@ import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
4 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 6
7
7 /** 8 /**
8 * @author XiangHan 9 * @author XiangHan
9 * @date 2021-10-22 10 * @date 2021-10-22
10 */ 11 */
11 public interface MemberRelatedInfoRepository extends JpaRepository<MemberRelatedInfo, Long>, JpaSpecificationExecutor<MemberRelatedInfo> { 12 public interface MemberRelatedInfoRepository extends JpaRepository<MemberRelatedInfo, Long>, JpaSpecificationExecutor<MemberRelatedInfo> {
12 13
14
15 MemberRelatedInfo findByIdCard(String idCard);
16
17 MemberRelatedInfo findByMemberIdAndIdCard(Long memberId , String idCard);
18
19 MemberRelatedInfo findByIdOrIdCard(Long id, String idCard);
13 } 20 }
......
1 package com.topdraw.business.module.member.relatedinfo.rest; 1 package com.topdraw.business.module.member.relatedinfo.rest;
2 2
3 import com.topdraw.aop.log.Log; 3 import com.topdraw.aop.log.Log;
4 import com.topdraw.business.common.CreateGroup; 4 import com.topdraw.business.module.common.validated.CreateGroup;
5 import com.topdraw.business.module.member.relatedinfo.domain.UpdateGroup; 5 import com.topdraw.business.module.common.validated.UpdateGroup;
6 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; 6 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
7 import com.topdraw.business.module.member.service.MemberService; 7 import com.topdraw.business.module.member.service.MemberService;
8 import com.topdraw.business.module.member.service.dto.MemberDTO; 8 import com.topdraw.business.module.member.service.dto.MemberDTO;
9 import com.topdraw.common.ResultInfo; 9 import com.topdraw.common.ResultInfo;
10 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; 10 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
11 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService; 11 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
12 import com.topdraw.exception.BadRequestException;
13 import com.topdraw.util.Base64Util;
14 import lombok.extern.slf4j.Slf4j; 12 import lombok.extern.slf4j.Slf4j;
15 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.util.Assert; 14 import org.springframework.util.Assert;
17 import org.springframework.util.StringUtils;
18 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
19 import org.springframework.web.bind.annotation.*; 16 import org.springframework.web.bind.annotation.*;
20 import io.swagger.annotations.*; 17 import io.swagger.annotations.*;
...@@ -42,13 +39,9 @@ public class MemberRelatedInfoController { ...@@ -42,13 +39,9 @@ public class MemberRelatedInfoController {
42 @ApiOperation("新增相关人员") 39 @ApiOperation("新增相关人员")
43 public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberRelatedInfo resources) { 40 public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberRelatedInfo resources) {
44 log.info("memberRelatedInfo ==>> create ==>> resources ===>> [{}]",resources); 41 log.info("memberRelatedInfo ==>> create ==>> resources ===>> [{}]",resources);
45 String name = resources.getName();
46 if (StringUtils.hasText(name)) {
47 String nickNameEncode = Base64Util.encode(name);
48 resources.setName(nickNameEncode);
49 }
50 42
51 this.memberRelatedInfoService.create(resources); 43 this.memberRelatedInfoService.create(resources);
44
52 return ResultInfo.success(); 45 return ResultInfo.success();
53 } 46 }
54 47
...@@ -59,21 +52,10 @@ public class MemberRelatedInfoController { ...@@ -59,21 +52,10 @@ public class MemberRelatedInfoController {
59 52
60 log.info("memberRelatedInfo ==>> update ==>> resources ===>> [{}]",resources); 53 log.info("memberRelatedInfo ==>> update ==>> resources ===>> [{}]",resources);
61 54
62 String name = resources.getName();
63 if (StringUtils.hasText(name)) {
64 String nickNameEncode = Base64Util.encode(name);
65 resources.setName(nickNameEncode);
66 }
67
68 Long id = resources.getId(); 55 Long id = resources.getId();
69 MemberRelatedInfoDTO memberRelatedInfoDTO = this.memberRelatedInfoService.findById(id); 56 MemberRelatedInfoDTO memberRelatedInfoDTO = this.memberRelatedInfoService.findById(id);
70 if (memberRelatedInfoDTO.getId() != null) { 57 if (memberRelatedInfoDTO.getId() != null) {
71 Long memberId = memberRelatedInfoDTO.getMemberId(); 58 Long memberId = memberRelatedInfoDTO.getMemberId();
72 if (Objects.isNull(memberId)) {
73 log.info("id ==>> [{}]",id);
74 throw new BadRequestException("memberId is null! please check member info");
75 }
76
77 MemberDTO memberDTO = this.memberService.findById(memberId); 59 MemberDTO memberDTO = this.memberService.findById(memberId);
78 if (Objects.nonNull(memberDTO)) { 60 if (Objects.nonNull(memberDTO)) {
79 String code = memberDTO.getCode(); 61 String code = memberDTO.getCode();
......
1 package com.topdraw.business.module.member.relatedinfo.service; 1 package com.topdraw.business.module.member.relatedinfo.service;
2 2
3 import com.topdraw.business.module.member.domain.Member;
3 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; 4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
4 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; 5 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
5 6
...@@ -16,10 +17,66 @@ public interface MemberRelatedInfoService { ...@@ -16,10 +17,66 @@ public interface MemberRelatedInfoService {
16 */ 17 */
17 MemberRelatedInfoDTO findById(Long id); 18 MemberRelatedInfoDTO findById(Long id);
18 19
20 /**
21 * 新增
22 * @param resources
23 */
19 void create(MemberRelatedInfo resources); 24 void create(MemberRelatedInfo resources);
20 25
26 /**
27 * 修改
28 * @param resources
29 */
21 void update(MemberRelatedInfo resources); 30 void update(MemberRelatedInfo resources);
22 31
32 /**
33 * 删除
34 * @param id
35 */
23 void delete(Long id); 36 void delete(Long id);
24 37
38 /**
39 * 通过身份证查询
40 * @param resources
41 * @return
42 */
43 MemberRelatedInfo findByIdCard(MemberRelatedInfo resources);
44
45 /**
46 * 通过身份证查询
47 * @param idCard 身份证
48 * @return
49 */
50 MemberRelatedInfo findByIdCard(String idCard);
51
52 /**
53 *
54 * @param memberId
55 * @param idCard
56 * @return
57 */
58 MemberRelatedInfo findByMemberIdAndIdCard(Long memberId , String idCard);
59
60 /**
61 *
62 * @param memberCode
63 * @param idCard
64 * @return
65 */
66 MemberRelatedInfo findByMemberCodeAndIdCard(String memberCode , String idCard);
67
68 /**
69 *
70 * @param resources
71 * @return
72 */
73 MemberRelatedInfo findByMemberIdAndIdCard(MemberRelatedInfo resources);
74
75 /**
76 *
77 * @param member
78 * @param resources
79 * @return
80 */
81 MemberRelatedInfo findByMemberIdAndIdCard(Member member , MemberRelatedInfo resources);
25 } 82 }
......
1 package com.topdraw.business.module.member.relatedinfo.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 /**
7 * @author XiangHan
8 * @date 2021-10-22
9 */
10 @Data
11 public class MemberRelatedInfoQueryCriteria{
12
13 @Query
14 private Long memberId;
15
16
17
18 }
1 package com.topdraw.business.module.member.relatedinfo.service.impl; 1 package com.topdraw.business.module.member.relatedinfo.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; 4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
5 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfoBuilder;
6 import com.topdraw.business.module.member.service.MemberService;
7 import com.topdraw.business.module.member.service.dto.MemberDTO;
8 import com.topdraw.exception.BadRequestException;
9 import com.topdraw.exception.GlobeExceptionMsg;
10 import com.topdraw.util.Base64Util;
11 import com.topdraw.util.RedissonUtil;
5 import com.topdraw.utils.ValidationUtil; 12 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.module.member.relatedinfo.repository.MemberRelatedInfoRepository; 13 import com.topdraw.business.module.member.relatedinfo.repository.MemberRelatedInfoRepository;
7 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService; 14 import com.topdraw.business.module.member.relatedinfo.service.MemberRelatedInfoService;
8 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO; 15 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoDTO;
9 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
10 import com.topdraw.business.module.member.relatedinfo.service.mapper.MemberRelatedInfoMapper; 16 import com.topdraw.business.module.member.relatedinfo.service.mapper.MemberRelatedInfoMapper;
17 import lombok.extern.slf4j.Slf4j;
18 import org.redisson.api.RLock;
19 import org.redisson.api.RedissonClient;
11 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 22 import org.springframework.transaction.annotation.Propagation;
14 import org.springframework.transaction.annotation.Transactional; 23 import org.springframework.transaction.annotation.Transactional;
15 import org.springframework.dao.EmptyResultDataAccessException; 24 import org.springframework.dao.EmptyResultDataAccessException;
16 import org.springframework.data.domain.Page;
17 import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert; 25 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil; 26 import org.springframework.util.StringUtils;
20 import com.topdraw.utils.QueryHelp;
21 27
22 import java.util.List; 28 import java.util.Objects;
23 import java.util.Map;
24 29
25 /** 30 /**
26 * @author XiangHan 31 * @author XiangHan
...@@ -28,47 +33,175 @@ import java.util.Map; ...@@ -28,47 +33,175 @@ import java.util.Map;
28 */ 33 */
29 @Service 34 @Service
30 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 35 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
36 @Slf4j
31 public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService { 37 public class MemberRelatedInfoServiceImpl implements MemberRelatedInfoService {
32 38
33 @Autowired 39 @Autowired
34 private MemberRelatedInfoRepository MemberRelatedInfoRepository; 40 private MemberService memberService;
41 @Autowired
42 private MemberRelatedInfoMapper memberRelatedInfoMapper;
43 @Autowired
44 private MemberRelatedInfoRepository memberRelatedInfoRepository;
35 45
36 @Autowired 46 @Autowired
37 private MemberRelatedInfoMapper MemberRelatedInfoMapper; 47 private RedissonClient redissonClient;
48
49
50 private static final String DEFAULT_IDCARD = "000000000000000000";
38 51
39 @Override 52 @Override
40 public MemberRelatedInfoDTO findById(Long id) { 53 public MemberRelatedInfoDTO findById(Long id) {
41 MemberRelatedInfo MemberRelatedInfo = MemberRelatedInfoRepository.findById(id).orElseGet(MemberRelatedInfo::new); 54 log.info("MemberRelatedInfoServiceImpl ==>> findById ==>> param ==>> [{}]",id);
42 ValidationUtil.isNull(MemberRelatedInfo.getId(),"MemberRelatedInfo","id",id); 55 MemberRelatedInfo memberRelatedInfo = this.memberRelatedInfoRepository.findById(id).orElseGet(MemberRelatedInfo::new);
43 return MemberRelatedInfoMapper.toDto(MemberRelatedInfo); 56 ValidationUtil.isNull(memberRelatedInfo.getId(),"MemberRelatedInfo","id",id);
57 return this.memberRelatedInfoMapper.toDto(memberRelatedInfo);
44 } 58 }
45 59
46 @Override 60 @Override
47 @Transactional(rollbackFor = Exception.class) 61 @Transactional(rollbackFor = Exception.class)
48 @AsyncMqSend()
49 public void create(MemberRelatedInfo resources) { 62 public void create(MemberRelatedInfo resources) {
50 MemberRelatedInfoRepository.save(resources); 63 log.info("MemberRelatedInfoServiceImpl ==>> create ==>> param ==>> [{}]",resources);
64 String idCard = resources.getIdCard();
65 Long memberId = resources.getMemberId();
66 if (Objects.nonNull(memberId) && !StringUtils.hasText(idCard) && !idCard.equalsIgnoreCase(DEFAULT_IDCARD) ) {
67 MemberRelatedInfo memberRelatedInfo = this.findByMemberIdAndIdCard(resources);
68 if (Objects.nonNull(memberRelatedInfo))
69 // 数据已存在
70 throw new BadRequestException(GlobeExceptionMsg.ENTITY_ALREADY_EXISTS);
71 }
72
73 this.checkMemberAndEncodeRealname(resources);
74
75 MemberRelatedInfo memberRelatedInfo = MemberRelatedInfoBuilder.build(resources);
76 this.memberRelatedInfoRepository.save(memberRelatedInfo);
77 log.info("MemberRelatedInfoServiceImpl ==>> create ==>> result ==>> [{}]",memberRelatedInfo);
78 }
79
80 /**
81 * 检查会员是否存在,加密真实姓名
82 * @param resources
83 */
84 private void checkMemberAndEncodeRealname(MemberRelatedInfo resources) {
85
86 // 检查会员是否存在
87 this.checkMember(resources);
88
89 // 加密真实姓名
90 this.encodeRealname(resources);
91 }
92
93 /**
94 * 加密真实姓名
95 * @param resources
96 * @return
97 */
98 private void encodeRealname(MemberRelatedInfo resources){
99 String name = resources.getName();
100 if (StringUtils.hasText(name)) {
101 String nickNameEncode = Base64Util.encode(name);
102 if (!nickNameEncode.equalsIgnoreCase(name))
103 resources.setName(nickNameEncode);
104 }
51 } 105 }
52 106
53 @Override 107 @Override
54 @Transactional(rollbackFor = Exception.class) 108 @Transactional(rollbackFor = Exception.class)
55 @AsyncMqSend()
56 public void update(MemberRelatedInfo resources) { 109 public void update(MemberRelatedInfo resources) {
57 MemberRelatedInfo MemberRelatedInfo = MemberRelatedInfoRepository.findById(resources.getId()).orElseGet(MemberRelatedInfo::new); 110 log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]",resources);
58 ValidationUtil.isNull( MemberRelatedInfo.getId(),"MemberRelatedInfo","id",resources.getId()); 111 RLock rLock = this.redissonClient.getLock("memberRelatedInfo::update::id" + resources.getId());
59 MemberRelatedInfo.copy(resources); 112 try {
60 MemberRelatedInfoRepository.save(MemberRelatedInfo); 113 RedissonUtil.lock(rLock);
114
115 this.checkMemberAndEncodeRealname(resources);
116
117 MemberRelatedInfo memberRelatedInfo = this.memberRelatedInfoRepository.findById(resources.getId()).orElseGet(MemberRelatedInfo::new);
118 ValidationUtil.isNull(memberRelatedInfo.getId(), "MemberRelatedInfo", "id", resources.getId());
119 memberRelatedInfo.copy(resources);
120
121 this.memberRelatedInfoRepository.save(memberRelatedInfo);
122
123 log.info("MemberRelatedInfoServiceImpl ==>> update ==>> param ==>> [{}]", resources);
124
125 } catch (Exception e) {
126 e.printStackTrace();
127 throw e;
128 } finally {
129 RedissonUtil.unlock(rLock);
130 }
61 } 131 }
62 132
63 @Override 133 @Override
64 @Transactional(rollbackFor = Exception.class) 134 @Transactional(rollbackFor = Exception.class)
65 @AsyncMqSend()
66 public void delete(Long id) { 135 public void delete(Long id) {
67 Assert.notNull(id, "The given id must not be null!"); 136 Assert.notNull(id, "The given id must not be null!");
68 MemberRelatedInfo MemberRelatedInfo = MemberRelatedInfoRepository.findById(id).orElseThrow( 137 MemberRelatedInfo MemberRelatedInfo = this.memberRelatedInfoRepository.findById(id).orElseThrow(
69 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberRelatedInfo.class, id), 1)); 138 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberRelatedInfo.class, id), 1));
70 MemberRelatedInfoRepository.delete(MemberRelatedInfo); 139 this.memberRelatedInfoRepository.delete(MemberRelatedInfo);
71 } 140 }
72 141
142 @Override
143 public MemberRelatedInfo findByIdCard(MemberRelatedInfo resources){
144 log.info("MemberRelatedInfoServiceImpl ==>> findByIdCard ==>> param ==>> [{}]",resources);
145 String idCard = resources.getIdCard();
146 Assert.notNull(idCard,"idCard can't be null");
147
148 if (!idCard.equalsIgnoreCase(DEFAULT_IDCARD)) {
149 MemberRelatedInfo memberRelatedInfo = this.findByIdCard(idCard);
150 ValidationUtil.isNull(memberRelatedInfo.getId(),"MemberRelatedInfo","id",resources.getId());
151 log.info("MemberRelatedInfoServiceImpl ==>> findByIdCard ==>> result ==>> [{}]",memberRelatedInfo);
152 return memberRelatedInfo;
153 }
154
155 return null;
156
157 }
158
159 @Override
160 public MemberRelatedInfo findByIdCard(String idCard) {
161 log.info("MemberRelatedInfoServiceImpl ==>> findByIdCard ==>> param ==>> [{}]",idCard);
162 MemberRelatedInfo memberRelatedInfo = this.memberRelatedInfoRepository.findByIdCard(idCard);
163 log.info("MemberRelatedInfoServiceImpl ==>> findByIdCard ==>> result ==>> [{}]",memberRelatedInfo);
164 return memberRelatedInfo;
165 }
166
167 @Override
168 public MemberRelatedInfo findByMemberCodeAndIdCard(String memberCode, String idCard) {
169 Assert.notNull(memberCode,"memberCode can't be null");
170 Assert.notNull(idCard,"idCard can't be null");
171 MemberDTO memberDTO = this.checkMember(null, memberCode);
172 return this.findByMemberIdAndIdCard(memberDTO.getId(),idCard);
173 }
174
175 @Override
176 public MemberRelatedInfo findByMemberIdAndIdCard(Long memberId, String idCard) {
177 log.info("MemberRelatedInfoServiceImpl ==>> findByMemberIdAndIdCard ==>> param ==>> [{}]",memberId+","+idCard);
178 MemberRelatedInfo memberRelatedInfo = this.memberRelatedInfoRepository.findByMemberIdAndIdCard(memberId, idCard);
179 log.info("MemberRelatedInfoServiceImpl ==>> findByMemberIdAndIdCard ==>> result ==>> [{}]",memberRelatedInfo);
180 return memberRelatedInfo;
181 }
182
183 @Override
184 public MemberRelatedInfo findByMemberIdAndIdCard(MemberRelatedInfo resources) {
185 Long memberId = resources.getMemberId();
186 String idCard = resources.getIdCard();
187 return this.findByMemberIdAndIdCard(memberId,idCard);
188 }
189
190 @Override
191 public MemberRelatedInfo findByMemberIdAndIdCard(Member member, MemberRelatedInfo resources) {
192 Long memberId = member.getId();
193 String idCard = resources.getIdCard();
194 return this.findByMemberIdAndIdCard(memberId,idCard);
195 }
196
197 private MemberDTO checkMember(MemberRelatedInfo resources){
198 Long memberId = resources.getMemberId();
199 String code = resources.getMemberCode();
200 return this.memberService.checkMember(memberId, code);
201 }
202
203 private MemberDTO checkMember(Long memberId , String memberCode){
204 return this.memberService.checkMember(memberId, memberCode);
205 }
73 206
74 } 207 }
......
1 package com.topdraw.business.module.member.rest; 1 package com.topdraw.business.module.member.rest;
2 2
3 import com.topdraw.aop.log.Log; 3 import com.topdraw.aop.log.Log;
4 import com.topdraw.business.common.CreateGroup; 4 import com.topdraw.business.module.common.validated.CreateGroup;
5 import com.topdraw.business.common.UpdateGroup; 5 import com.topdraw.business.module.common.validated.UpdateGroup;
6 import com.topdraw.business.module.member.domain.Member; 6 import com.topdraw.business.module.member.domain.Member;
7 import com.topdraw.business.module.member.service.MemberService; 7 import com.topdraw.business.module.member.service.MemberService;
8 import com.topdraw.business.module.user.iptv.domain.UserTv; 8 import com.topdraw.business.module.user.iptv.domain.UserTv;
...@@ -34,24 +34,15 @@ public class MemberController { ...@@ -34,24 +34,15 @@ public class MemberController {
34 @Log("为大屏账户创建会员") 34 @Log("为大屏账户创建会员")
35 @RequestMapping(value = "/createMemberByUserTv") 35 @RequestMapping(value = "/createMemberByUserTv")
36 @ApiOperation("为大屏账户创建会员") 36 @ApiOperation("为大屏账户创建会员")
37 @Deprecated
37 public ResultInfo createMemberByUserTv(@Validated(value = {CreateGroup.class}) @RequestBody UserTv resources) { 38 public ResultInfo createMemberByUserTv(@Validated(value = {CreateGroup.class}) @RequestBody UserTv resources) {
38 // todo 此接口废弃,将移动至UserTvController中,AppEngine也要同步修改 39 // todo 此接口废弃,将移动至UserTvController中,AppEngine也要同步修改
39 log.info("member ==>> createMemberByUserTv ==>> param ==>> [{}]",resources); 40 log.info("member ==>> createMemberByUserTv ==>> param ==>> [{}]",resources);
40 boolean result = this.userTvOperationService.createMemberByUserTv(resources); 41 boolean result = this.userTvOperationService.createTvUserAndCreateMember(resources);
41 log.info("member ==>> createMemberByUserTv ==>> result ==>> [{}]",result); 42 log.info("member ==>> createMemberByUserTv ==>> result ==>> [{}]",result);
42 return ResultInfo.success(result); 43 return ResultInfo.success(result);
43 } 44 }
44 45
45 @Log("新增会员")
46 @RequestMapping(value = "/create")
47 @ApiOperation("新增会员")
48 public ResultInfo create(@Validated @RequestBody Member resources) {
49 log.info("member ==>> create ==>> param ==>> [{}]",resources);
50 Long id = memberService.create(resources);
51 log.info("member ==>> create ==>> result ==>> [{}]",resources);
52 return ResultInfo.success(id);
53 }
54
55 @Log("手动修改vip") 46 @Log("手动修改vip")
56 @RequestMapping(value = "/doUpdateVipByCode") 47 @RequestMapping(value = "/doUpdateVipByCode")
57 @ApiOperation("手动修改vip") 48 @ApiOperation("手动修改vip")
...@@ -61,14 +52,4 @@ public class MemberController { ...@@ -61,14 +52,4 @@ public class MemberController {
61 log.info("member ==>> doUpdateVipByCode ==>> result ==>> [{}]",resources); 52 log.info("member ==>> doUpdateVipByCode ==>> result ==>> [{}]",resources);
62 return ResultInfo.success(); 53 return ResultInfo.success();
63 } 54 }
64
65 @Log("修改会员")
66 @RequestMapping(value = "/update")
67 @ApiOperation("修改会员")
68 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) {
69 log.info("member ==>> update ==>> param ==>> [{}]",resources);
70 memberService.update(resources);
71 log.info("member ==>> update ==>> result ==>> [{}]",resources);
72 return ResultInfo.success();
73 }
74 } 55 }
......
...@@ -26,14 +26,6 @@ public interface MemberService { ...@@ -26,14 +26,6 @@ public interface MemberService {
26 MemberDTO findByCode(String code); 26 MemberDTO findByCode(String code);
27 27
28 /** 28 /**
29 *
30 * @param id
31 * @param code
32 * @return
33 */
34 MemberDTO findByIdOrCode(Long id,String code);
35
36 /**
37 * 保存 29 * 保存
38 * @param resources 30 * @param resources
39 * @return Long id 31 * @return Long id
...@@ -54,13 +46,6 @@ public interface MemberService { ...@@ -54,13 +46,6 @@ public interface MemberService {
54 void update(Member resources); 46 void update(Member resources);
55 47
56 /** 48 /**
57 * 解绑
58 * @param resources 会员
59 * @return Map<String,Object>
60 */
61 void unbind(Member resources);
62
63 /**
64 * 修改会员积分 49 * 修改会员积分
65 * @param member 会员 50 * @param member 会员
66 */ 51 */
...@@ -72,4 +57,17 @@ public interface MemberService { ...@@ -72,4 +57,17 @@ public interface MemberService {
72 * @return Map<String,Object> 57 * @return Map<String,Object>
73 */ 58 */
74 List<MemberDTO> findByUserIptvId(Long id); 59 List<MemberDTO> findByUserIptvId(Long id);
60
61 /**
62 * 检查会员信息
63 * @param id 会员id
64 * @param memberCode 会员编码
65 */
66 MemberDTO checkMember(Long id , String memberCode);
67
68 /**
69 * 检查会员信息
70 * @param member 会员
71 */
72 MemberDTO checkMember(Member member);
75 } 73 }
......
1 package com.topdraw.business.module.member.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 /**
7 * @author XiangHan
8 * @date 2021-10-22
9 */
10 @Data
11 public class MemberQueryCriteria{
12
13 @Query(type = Query.Type.LEFT_LIKE)
14 private String code;
15
16 // 类型 1:大屏;2:小屏
17 @Query(type = Query.Type.EQUAL)
18 private Integer type;
19
20 // 状态 0:不可用;1:可用
21 @Query(type = Query.Type.EQUAL)
22 private Integer status;
23
24 // 昵称 base64
25 @Query(type = Query.Type.LEFT_LIKE)
26 private String nickname;
27
28 // 性别 0:女;1:男;-1:未知
29 @Query(type = Query.Type.EQUAL)
30 private Integer gender;
31
32 // 分组信息
33 @Query(type = Query.Type.EQUAL)
34 private String groups;
35
36 // 标签
37 @Query(type = Query.Type.IN)
38 private String tags;
39
40 // 是否会员 0:非会员;1:会员
41 @Query(type = Query.Type.EQUAL)
42 private Integer vip;
43
44 // 会员等级(对应level表的level字段,非id)
45 @Query(type = Query.Type.EQUAL)
46 private Integer level;
47
48 // iptv账号id
49 @Query(type = Query.Type.EQUAL)
50 private Long userIptvId;
51
52 // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通
53 @Query(type = Query.Type.IN)
54 private Integer bindIptvPlatformType;
55
56 }
...@@ -9,12 +9,14 @@ import com.topdraw.business.module.member.service.MemberService; ...@@ -9,12 +9,14 @@ import com.topdraw.business.module.member.service.MemberService;
9 import com.topdraw.business.module.member.service.dto.MemberDTO; 9 import com.topdraw.business.module.member.service.dto.MemberDTO;
10 import com.topdraw.business.module.member.service.mapper.MemberMapper; 10 import com.topdraw.business.module.member.service.mapper.MemberMapper;
11 import com.topdraw.exception.BadRequestException; 11 import com.topdraw.exception.BadRequestException;
12 import com.topdraw.exception.GlobeExceptionMsg;
12 import com.topdraw.util.RedissonUtil; 13 import com.topdraw.util.RedissonUtil;
13 import com.topdraw.utils.StringUtils;
14 import com.topdraw.utils.ValidationUtil; 14 import com.topdraw.utils.ValidationUtil;
15 import lombok.extern.slf4j.Slf4j; 15 import lombok.extern.slf4j.Slf4j;
16 import org.apache.commons.lang3.StringUtils;
16 import org.redisson.api.RLock; 17 import org.redisson.api.RLock;
17 import org.redisson.api.RedissonClient; 18 import org.redisson.api.RedissonClient;
19 import org.springframework.beans.BeanUtils;
18 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
20 import org.springframework.transaction.annotation.Propagation; 22 import org.springframework.transaction.annotation.Propagation;
...@@ -42,35 +44,66 @@ public class MemberServiceImpl implements MemberService { ...@@ -42,35 +44,66 @@ public class MemberServiceImpl implements MemberService {
42 44
43 @Override 45 @Override
44 public MemberDTO findById(Long id) { 46 public MemberDTO findById(Long id) {
47
45 Member member = this.memberRepository.findById(id).orElseGet(Member::new); 48 Member member = this.memberRepository.findById(id).orElseGet(Member::new);
46 ValidationUtil.isNull(member.getId(),"Member","id",id); 49 ValidationUtil.isNull(member.getId(),"Member","id",id);
50
47 return memberMapper.toDto(member); 51 return memberMapper.toDto(member);
52
48 } 53 }
49 54
50 @Override 55 @Override
51 public MemberDTO findByCode(String code) { 56 public MemberDTO findByCode(String code) {
57
52 Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new); 58 Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new);
53 ValidationUtil.isNull(member.getId(),"Member","id",code); 59 ValidationUtil.isNull(member.getId(),"Member","id",code);
60
54 return memberMapper.toDto(member); 61 return memberMapper.toDto(member);
62
55 } 63 }
56 64
57 @Override 65 private MemberDTO findByIdOrCode(Long id,String code) {
58 public MemberDTO findByIdOrCode(Long id,String code) { 66
59 Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new); 67 Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new);
60 ValidationUtil.isNull(member.getId(),"Member","param",code); 68 ValidationUtil.isNull(member.getId(),"Member","param",code);
69
61 return memberMapper.toDto(member); 70 return memberMapper.toDto(member);
71
62 } 72 }
63 73
64 @Override 74 @Override
65 public List<MemberDTO> findByUserIptvId(Long id) { 75 public List<MemberDTO> findByUserIptvId(Long id) {
76
66 List<Member> memberList = this.memberRepository.findByUserIptvId(id); 77 List<Member> memberList = this.memberRepository.findByUserIptvId(id);
78
67 return memberMapper.toDto(memberList); 79 return memberMapper.toDto(memberList);
80
81 }
82
83 @Override
84 public MemberDTO checkMember(Long id, String memberCode) {
85
86 if(Objects.isNull(id) && StringUtils.isBlank(memberCode))
87 throw new BadRequestException(GlobeExceptionMsg.MEMBER_ID_AND_CODE_ARE_NULL);
88
89 return this.findByIdOrCode(id, memberCode);
90 }
91
92 @Override
93 public MemberDTO checkMember(Member member) {
94
95 String memberCode = member.getCode();
96 Long memberId = member.getId();
97
98 return this.checkMember(memberId,memberCode);
99
68 } 100 }
69 101
70 @Override 102 @Override
71 @Transactional(rollbackFor = Exception.class) 103 @Transactional(rollbackFor = Exception.class)
72 @AsyncMqSend() 104 @AsyncMqSend()
73 public Long create(Member resources) { 105 public Long create(Member resources) {
106
74 Member member = MemberBuilder.build(resources); 107 Member member = MemberBuilder.build(resources);
75 Long memberId = this.save(member); 108 Long memberId = this.save(member);
76 109
...@@ -79,15 +112,18 @@ public class MemberServiceImpl implements MemberService { ...@@ -79,15 +112,18 @@ public class MemberServiceImpl implements MemberService {
79 this.memberProfileService.createDefault(member); 112 this.memberProfileService.createDefault(member);
80 113
81 return member.getId(); 114 return member.getId();
115
82 } 116 }
83 117
84 @Override 118 @Override
85 @Transactional(rollbackFor = Exception.class) 119 @Transactional(rollbackFor = Exception.class)
86 @AsyncMqSend() 120 @AsyncMqSend()
87 public Member createAndReturnMember(Member resources) { 121 public Member createAndReturnMember(Member resources) {
88 Member member = MemberBuilder.build(resources); 122
89 this.create(member); 123 this.create(MemberBuilder.build(resources));
124
90 return resources; 125 return resources;
126
91 } 127 }
92 128
93 @Override 129 @Override
...@@ -96,43 +132,24 @@ public class MemberServiceImpl implements MemberService { ...@@ -96,43 +132,24 @@ public class MemberServiceImpl implements MemberService {
96 public void update(Member resources) { 132 public void update(Member resources) {
97 133
98 log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); 134 log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources);
99 String code = resources.getCode();
100 if (StringUtils.isBlank(code))
101 throw new BadRequestException("memberCode can't be null!!");
102
103 RLock rLock = this.redissonClient.getLock("member::update::code" + resources.getCode()); 135 RLock rLock = this.redissonClient.getLock("member::update::code" + resources.getCode());
104 try { 136 try {
105 RedissonUtil.lock(rLock); 137 RedissonUtil.lock(rLock);
106 Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new); 138 MemberDTO memberDTO = this.checkMember(resources);
107 ValidationUtil.isNull(member.getCode(), "Member", "code", resources.getCode()); 139
140 Member member = new Member();
141 BeanUtils.copyProperties(memberDTO,member);
108 member.copy(resources); 142 member.copy(resources);
109 143
110 this.save(member); 144 this.save(member);
111 } catch (Exception e) {
112 e.printStackTrace();
113 throw e;
114 } finally {
115 RedissonUtil.unlock(rLock);
116 }
117 }
118 145
119 @Override
120 @Transactional(rollbackFor = Exception.class)
121 @AsyncMqSend()
122 public void unbind(Member resources) {
123 RLock rLock = this.redissonClient.getLock("member::update::code" + resources.getCode());
124 try {
125 RedissonUtil.lock(rLock);
126 Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new);
127 ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId());
128 member.copy(resources);
129 this.save(member);
130 } catch (Exception e) { 146 } catch (Exception e) {
131 e.printStackTrace(); 147 e.printStackTrace();
132 throw e; 148 throw e;
133 } finally { 149 } finally {
134 RedissonUtil.unlock(rLock); 150 RedissonUtil.unlock(rLock);
135 } 151 }
152
136 } 153 }
137 154
138 @Transactional(propagation = Propagation.REQUIRES_NEW) 155 @Transactional(propagation = Propagation.REQUIRES_NEW)
...@@ -160,6 +177,4 @@ public class MemberServiceImpl implements MemberService { ...@@ -160,6 +177,4 @@ public class MemberServiceImpl implements MemberService {
160 } 177 }
161 } 178 }
162 179
163
164
165 } 180 }
......
...@@ -2,6 +2,7 @@ package com.topdraw.business.module.member.viphistory.domain; ...@@ -2,6 +2,7 @@ package com.topdraw.business.module.member.viphistory.domain;
2 2
3 import cn.hutool.core.bean.BeanUtil; 3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.bean.copier.CopyOptions; 4 import cn.hutool.core.bean.copier.CopyOptions;
5 import com.topdraw.business.module.common.domain.AsyncMqModule;
5 import lombok.Data; 6 import lombok.Data;
6 import lombok.experimental.Accessors; 7 import lombok.experimental.Accessors;
7 import org.springframework.data.annotation.CreatedDate; 8 import org.springframework.data.annotation.CreatedDate;
...@@ -22,7 +23,7 @@ import java.time.LocalDateTime; ...@@ -22,7 +23,7 @@ import java.time.LocalDateTime;
22 @EntityListeners(AuditingEntityListener.class) 23 @EntityListeners(AuditingEntityListener.class)
23 @Accessors(chain = true) 24 @Accessors(chain = true)
24 @Table(name="uc_member_vip_history") 25 @Table(name="uc_member_vip_history")
25 public class MemberVipHistory implements Serializable { 26 public class MemberVipHistory extends AsyncMqModule implements Serializable {
26 27
27 // 主键 28 // 主键
28 @Id 29 @Id
......
1 package com.topdraw.business.module.member.viphistory.rest;
2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
5 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
6 import com.topdraw.common.ResultInfo;
7 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.data.domain.Pageable;
11 import org.springframework.validation.annotation.Validated;
12 import org.springframework.web.bind.annotation.*;
13
14 /**
15 * @author luerlong
16 * @date 2021-12-10
17 */
18 @Api(tags = "MemberVipHistory管理")
19 @RestController
20 @RequestMapping("/api/memberVipHistory")
21 public class MemberVipHistoryController {
22
23 @Autowired
24 private MemberVipHistoryService memberVipHistoryService;
25
26 @PostMapping
27 @ApiOperation("新增MemberVipHistory")
28 public ResultInfo create(@Validated @RequestBody MemberVipHistory resources) {
29 memberVipHistoryService.create(resources);
30 return ResultInfo.success();
31 }
32
33 @PutMapping
34 @ApiOperation("修改MemberVipHistory")
35 public ResultInfo update(@Validated @RequestBody MemberVipHistory resources) {
36 memberVipHistoryService.update(resources);
37 return ResultInfo.success();
38 }
39
40 @DeleteMapping(value = "/{id}")
41 @ApiOperation("删除MemberVipHistory")
42 public ResultInfo delete(@PathVariable Long id) {
43 memberVipHistoryService.delete(id);
44 return ResultInfo.success();
45 }
46
47 }
...@@ -2,13 +2,8 @@ package com.topdraw.business.module.member.viphistory.service; ...@@ -2,13 +2,8 @@ package com.topdraw.business.module.member.viphistory.service;
2 2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; 3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO; 4 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
5 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7 5
8 import java.time.LocalDateTime; 6 import java.time.LocalDateTime;
9 import java.util.List;
10 import java.util.Map;
11 import java.util.Optional;
12 7
13 /** 8 /**
14 * @author luerlong 9 * @author luerlong
...@@ -17,32 +12,35 @@ import java.util.Optional; ...@@ -17,32 +12,35 @@ import java.util.Optional;
17 public interface MemberVipHistoryService { 12 public interface MemberVipHistoryService {
18 13
19 /** 14 /**
20 * 查询数据分页
21 * @param criteria 条件参数
22 * @param pageable 分页参数
23 * @return Map<String,Object>
24 */
25 Map<String,Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable);
26
27 /**
28 * 查询所有数据不分页
29 * @param criteria 条件参数
30 * @return List<MemberVipHistoryDTO>
31 */
32 List<MemberVipHistoryDTO> queryAll(MemberVipHistoryQueryCriteria criteria);
33
34 /**
35 * 根据ID查询 15 * 根据ID查询
36 * @param id ID 16 * @param id ID
37 * @return MemberVipHistoryDTO 17 * @return MemberVipHistoryDTO
38 */ 18 */
39 MemberVipHistoryDTO findById(Long id); 19 MemberVipHistoryDTO findById(Long id);
40 20
21 /**
22 *
23 * @param resources
24 */
41 void create(MemberVipHistory resources); 25 void create(MemberVipHistory resources);
42 26
27 /**
28 *
29 * @param resources
30 */
43 void update(MemberVipHistory resources); 31 void update(MemberVipHistory resources);
44 32
33 /**
34 *
35 * @param id
36 */
45 void delete(Long id); 37 void delete(Long id);
46 38
39 /**
40 *
41 * @param id
42 * @param nowTime
43 * @return
44 */
47 MemberVipHistory findByTime(Long id, LocalDateTime nowTime); 45 MemberVipHistory findByTime(Long id, LocalDateTime nowTime);
48 } 46 }
......
1 package com.topdraw.business.module.member.viphistory.service.impl; 1 package com.topdraw.business.module.member.viphistory.service.impl;
2 2
3 3
4 import com.topdraw.business.module.member.service.MemberService;
5 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; 6 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
5 import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository; 7 import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository;
6 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; 8 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
7 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO; 9 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
8 import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
9 import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHistoryMapper; 10 import com.topdraw.business.module.member.viphistory.service.mapper.MemberVipHistoryMapper;
10 import com.topdraw.utils.PageUtil;
11 import com.topdraw.utils.QueryHelp;
12 import com.topdraw.utils.ValidationUtil; 11 import com.topdraw.utils.ValidationUtil;
12 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.dao.EmptyResultDataAccessException; 14 import org.springframework.dao.EmptyResultDataAccessException;
15 import org.springframework.data.domain.Page;
16 import org.springframework.data.domain.Pageable;
17 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Propagation; 16 import org.springframework.transaction.annotation.Propagation;
19 import org.springframework.transaction.annotation.Transactional; 17 import org.springframework.transaction.annotation.Transactional;
20 import org.springframework.util.Assert; 18 import org.springframework.util.Assert;
21 19
22 import java.time.LocalDateTime; 20 import java.time.LocalDateTime;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Optional;
26 21
27 /** 22 /**
28 * @author luerlong 23 * @author luerlong
...@@ -30,35 +25,31 @@ import java.util.Optional; ...@@ -30,35 +25,31 @@ import java.util.Optional;
30 */ 25 */
31 @Service 26 @Service
32 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 27 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
28 @Slf4j
33 public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { 29 public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
34 30
35 @Autowired 31 @Autowired
36 private MemberVipHistoryRepository memberVipHistoryRepository; 32 private MemberService memberService;
37 33
38 @Autowired 34 @Autowired
39 private MemberVipHistoryMapper memberVipHistoryMapper; 35 private MemberVipHistoryMapper memberVipHistoryMapper;
40 36 @Autowired
41 @Override 37 private MemberVipHistoryRepository memberVipHistoryRepository;
42 public Map<String, Object> queryAll(MemberVipHistoryQueryCriteria criteria, Pageable pageable) {
43 Page<MemberVipHistory> page = memberVipHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
44 return PageUtil.toPage(page.map(memberVipHistoryMapper::toDto));
45 }
46
47 @Override
48 public List<MemberVipHistoryDTO> queryAll(MemberVipHistoryQueryCriteria criteria) {
49 return memberVipHistoryMapper.toDto(memberVipHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
50 }
51 38
52 @Override 39 @Override
53 public MemberVipHistoryDTO findById(Long id) { 40 public MemberVipHistoryDTO findById(Long id) {
41 log.info("MemberVipHistoryServiceImpl ==>> findById ==>> param ==>> [{}]",id);
54 MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseGet(MemberVipHistory::new); 42 MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseGet(MemberVipHistory::new);
55 ValidationUtil.isNull(memberVipHistory.getId(),"MemberVipHistory","id",id); 43 ValidationUtil.isNull(memberVipHistory.getId(),"MemberVipHistory","id",id);
44 log.info("MemberVipHistoryServiceImpl ==>> findById ==>> result ==>> [{}]",memberVipHistory);
56 return memberVipHistoryMapper.toDto(memberVipHistory); 45 return memberVipHistoryMapper.toDto(memberVipHistory);
57 } 46 }
58 47
59 @Override 48 @Override
60 @Transactional(rollbackFor = Exception.class) 49 @Transactional(rollbackFor = Exception.class)
61 public void create(MemberVipHistory resources) { 50 public void create(MemberVipHistory resources) {
51 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources);
52 this.checkMember(resources);
62 memberVipHistoryRepository.save(resources); 53 memberVipHistoryRepository.save(resources);
63 } 54 }
64 55
...@@ -86,5 +77,10 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { ...@@ -86,5 +77,10 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
86 return memberVipHistory; 77 return memberVipHistory;
87 } 78 }
88 79
80 private MemberDTO checkMember(MemberVipHistory resources){
81 Long memberId = resources.getMemberId();
82 String code = resources.getMemberCode();
83 return this.memberService.checkMember(memberId, code);
84 }
89 85
90 } 86 }
......
1 package com.topdraw.business.module.points.available.domain; 1 package com.topdraw.business.module.points.available.domain;
2 2
3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; 3 import com.topdraw.business.module.common.domain.AsyncMqModule;
4 import lombok.Data; 4 import lombok.Data;
5 import lombok.experimental.Accessors; 5 import lombok.experimental.Accessors;
6 import cn.hutool.core.bean.BeanUtil; 6 import cn.hutool.core.bean.BeanUtil;
...@@ -25,7 +25,7 @@ import java.io.Serializable; ...@@ -25,7 +25,7 @@ import java.io.Serializable;
25 @EntityListeners(AuditingEntityListener.class) 25 @EntityListeners(AuditingEntityListener.class)
26 @Accessors(chain = true) 26 @Accessors(chain = true)
27 @Table(name="uc_points_available") 27 @Table(name="uc_points_available")
28 public class PointsAvailable extends DefaultAsyncMqModule implements Serializable { 28 public class PointsAvailable extends AsyncMqModule implements Serializable {
29 29
30 // 主键 30 // 主键
31 @Id 31 @Id
......
1 package com.topdraw.business.module.rights.history.domain; 1 package com.topdraw.business.module.rights.history.domain;
2 2
3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; 3 import com.topdraw.business.module.common.domain.AsyncMqModule;
4 import lombok.Data; 4 import lombok.Data;
5 import lombok.experimental.Accessors; 5 import lombok.experimental.Accessors;
6 import cn.hutool.core.bean.BeanUtil; 6 import cn.hutool.core.bean.BeanUtil;
...@@ -23,7 +23,7 @@ import java.time.LocalDateTime; ...@@ -23,7 +23,7 @@ import java.time.LocalDateTime;
23 @EntityListeners(AuditingEntityListener.class) 23 @EntityListeners(AuditingEntityListener.class)
24 @Accessors(chain = true) 24 @Accessors(chain = true)
25 @Table(name="tr_rights_histroy") 25 @Table(name="tr_rights_histroy")
26 public class RightsHistory extends DefaultAsyncMqModule implements Serializable { 26 public class RightsHistory extends AsyncMqModule implements Serializable {
27 27
28 // 主键id 28 // 主键id
29 @Id 29 @Id
......
1 package com.topdraw.business.module.user.iptv.domain; 1 package com.topdraw.business.module.user.iptv.domain;
2 2
3 import com.topdraw.business.common.CreateGroup; 3 import com.topdraw.business.module.common.domain.AsyncMqModule;
4 import com.topdraw.business.common.UpdateGroup; 4 import com.topdraw.business.module.common.validated.CreateGroup;
5 import lombok.Data; 5 import lombok.Data;
6 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
7 import cn.hutool.core.bean.BeanUtil; 7 import cn.hutool.core.bean.BeanUtil;
...@@ -25,15 +25,11 @@ import java.io.Serializable; ...@@ -25,15 +25,11 @@ import java.io.Serializable;
25 @EntityListeners(AuditingEntityListener.class) 25 @EntityListeners(AuditingEntityListener.class)
26 @Accessors(chain = true) 26 @Accessors(chain = true)
27 @Table(name="uc_user_tv") 27 @Table(name="uc_user_tv")
28 public class UserTv implements Serializable { 28 public class UserTv extends AsyncMqModule implements Serializable {
29 29
30 /** 绑定的小屏账户会员编码 */ 30 /** 绑定的小屏账户会员编码 */
31 @Column(name = "priority_member_code") 31 @Column(name = "priority_member_code")
32 private String priorityMemberCode; 32 private String priorityMemberCode;
33
34 @Transient
35 private String memberCode;
36
37 // ID 33 // ID
38 @Id 34 @Id
39 @GeneratedValue(strategy = GenerationType.IDENTITY) 35 @GeneratedValue(strategy = GenerationType.IDENTITY)
......
1 package com.topdraw.business.module.user.iptv.domain;
2
3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.exception.BadRequestException;
5 import com.topdraw.exception.GlobeExceptionMsg;
6 import com.topdraw.util.TimestampUtil;
7 import org.apache.commons.lang3.StringUtils;
8
9 /**
10 * @author :
11 * @description:
12 * @function :
13 * @date :Created in 2022/3/14 14:36
14 * @version: :
15 * @modified By:
16 * @since : modified in 2022/3/14 14:36
17 */
18 public class UserTvBuilder {
19
20 public static UserTv build(UserTv userTv){
21 return build(userTv.getMemberCode(),userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
22 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy());
23 }
24
25 public static UserTv build(String memberCode , UserTv userTv){
26 return build(memberCode,userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
27 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy());
28 }
29
30 public static UserTv build(Member member ,UserTv userTv){
31 return build(member.getCode(),userTv.getId(),userTv.getPlatformAccount(),userTv.getNickname(),userTv.getUsername(),
32 userTv.getLoginDays(),userTv.getStatus(),userTv.getContinueDays(),userTv.getCreateBy(),userTv.getUpdateBy());
33 }
34
35 public static UserTv build(String memberCode , Long id , String platformAccount , String nickname , String username,
36 int loginDays , int status ,int continueDays , String createBy , String updateBy){
37
38 if (StringUtils.isBlank(platformAccount))
39 throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL);
40
41 // todo 原型模式
42
43 UserTv userTv = new UserTv();
44 userTv.setId(id);
45 userTv.setPlatformAccount(platformAccount);
46 userTv.setMemberCode(memberCode);
47 userTv.setNickname(StringUtils.isBlank(nickname)?platformAccount:nickname);
48 userTv.setUsername(StringUtils.isBlank(username)?platformAccount:username);
49 userTv.setLoginDays(loginDays);
50 userTv.setStatus(status);
51 userTv.setActiveTime(TimestampUtil.now());
52 userTv.setContinueDays(continueDays);
53 userTv.setCreateBy(StringUtils.isBlank(createBy)?"system":createBy);
54 userTv.setUpdateBy(StringUtils.isBlank(updateBy)?"system":updateBy);
55 return userTv;
56 }
57
58 }
1 package com.topdraw.business.module.user.iptv.rest;
2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.common.ResultInfo;
5 import com.topdraw.business.module.user.iptv.domain.UserTv;
6 import com.topdraw.business.module.user.iptv.service.UserTvService;
7 import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable;
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 2021-12-16
17 */
18 @Api(tags = "UserTv管理")
19 @RestController
20 @RequestMapping("/ucEngine/api/userTv")
21 public class UserTvController {
22
23 @Autowired
24 private UserTvService UserTvService;
25
26 @GetMapping
27 @ApiOperation("查询UserTv")
28 public ResultInfo getUserTvs(UserTvQueryCriteria criteria, Pageable pageable) {
29 return ResultInfo.successPage(UserTvService.queryAll(criteria,pageable));
30 }
31
32 @GetMapping(value = "/all")
33 @ApiOperation("查询所有UserTv")
34 public ResultInfo getUserTvs(UserTvQueryCriteria criteria) {
35 return ResultInfo.success(UserTvService.queryAll(criteria));
36 }
37
38 @PostMapping(value = "/create")
39 @ApiOperation("新增UserTv")
40 @AnonymousAccess
41 public ResultInfo create(@Validated @RequestBody UserTv resources) {
42 UserTvService.create(resources);
43 return ResultInfo.success();
44 }
45
46 @PutMapping
47 @ApiOperation("修改UserTv")
48 @AnonymousAccess
49 public ResultInfo update(@Validated @RequestBody UserTv resources) {
50 UserTvService.update(resources);
51 return ResultInfo.success();
52 }
53
54 @DeleteMapping(value = "/{id}")
55 @ApiOperation("删除UserTv")
56 public ResultInfo delete(@PathVariable Long id) {
57 UserTvService.delete(id);
58 return ResultInfo.success();
59 }
60
61 }
1 package com.topdraw.business.module.user.iptv.service; 1 package com.topdraw.business.module.user.iptv.service;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.business.module.member.service.dto.MemberDTO;
4 import com.topdraw.business.module.user.iptv.domain.UserTv; 4 import com.topdraw.business.module.user.iptv.domain.UserTv;
5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
6 import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
7 import org.springframework.data.domain.Pageable;
8 import org.springframework.transaction.annotation.Transactional;
9
10 import java.util.Map;
11 import java.util.List;
12 6
13 /** 7 /**
14 * @author XiangHan 8 * @author XiangHan
...@@ -17,38 +11,65 @@ import java.util.List; ...@@ -17,38 +11,65 @@ import java.util.List;
17 public interface UserTvService { 11 public interface UserTvService {
18 12
19 /** 13 /**
20 * 查询数据分页
21 * @param criteria 条件参数
22 * @param pageable 分页参数
23 * @return Map<String,Object>
24 */
25 Map<String,Object> queryAll(UserTvQueryCriteria criteria, Pageable pageable);
26
27 /**
28 * 查询所有数据不分页
29 * @param criteria 条件参数
30 * @return List<UserTvDTO>
31 */
32 List<UserTvDTO> queryAll(UserTvQueryCriteria criteria);
33
34 /**
35 * 根据ID查询 14 * 根据ID查询
36 * @param id ID 15 * @param id ID
37 * @return UserTvDTO 16 * @return UserTvDTO
38 */ 17 */
39 UserTvDTO findById(Long id); 18 UserTvDTO findById(Long id);
40 19
41 Long create(UserTv resources); 20 /**
21 *
22 * @param resources
23 * @return
24 */
25 UserTv create(UserTv resources);
42 26
27 /**
28 *
29 * @param resources
30 */
43 void update(UserTv resources); 31 void update(UserTv resources);
44 32
33 /**
34 *
35 * @param resources
36 */
45 void unbindPriorityMemberCode(UserTv resources); 37 void unbindPriorityMemberCode(UserTv resources);
46 38
39 /**
40 *
41 * @param id
42 */
47 void delete(Long id); 43 void delete(Long id);
48 44
45 /**
46 *
47 * @param platformAccount
48 * @return
49 */
49 UserTvDTO findByPlatformAccount(String platformAccount); 50 UserTvDTO findByPlatformAccount(String platformAccount);
50 51
52 /**
53 *
54 * @param memberCode
55 * @return
56 */
51 UserTvDTO findByPriorityMemberCode(String memberCode); 57 UserTvDTO findByPriorityMemberCode(String memberCode);
52 58
59 /**
60 * 通过会员
61 * @param memberId
62 * @return
63 */
53 UserTvDTO findByMemberId(Long memberId); 64 UserTvDTO findByMemberId(Long memberId);
65
66 /**
67 * 检查会员是否是主账号
68 * @param memberId
69 * @param memberCode
70 * @return
71 */
72 boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId,String memberCode);
73
74 MemberDTO findMemberByPlatformAccount(String platformAccount);
54 } 75 }
......
1 package com.topdraw.business.module.user.iptv.service.impl; 1 package com.topdraw.business.module.user.iptv.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.member.service.MemberService; 3 import com.topdraw.business.module.member.service.MemberService;
5 import com.topdraw.business.module.member.service.dto.MemberDTO; 4 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.module.user.iptv.domain.UserTv; 5 import com.topdraw.business.module.user.iptv.domain.UserTv;
6 import com.topdraw.exception.EntityNotFoundException;
7 import com.topdraw.exception.GlobeExceptionMsg;
7 import com.topdraw.utils.ValidationUtil; 8 import com.topdraw.utils.ValidationUtil;
8 import com.topdraw.business.module.user.iptv.repository.UserTvRepository; 9 import com.topdraw.business.module.user.iptv.repository.UserTvRepository;
9 import com.topdraw.business.module.user.iptv.service.UserTvService; 10 import com.topdraw.business.module.user.iptv.service.UserTvService;
10 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 11 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
11 import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
12 import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; 12 import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper;
13 import org.apache.commons.lang3.StringUtils;
13 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
15 import org.springframework.transaction.annotation.Propagation; 16 import org.springframework.transaction.annotation.Propagation;
16 import org.springframework.transaction.annotation.Transactional; 17 import org.springframework.transaction.annotation.Transactional;
17 import org.springframework.dao.EmptyResultDataAccessException; 18 import org.springframework.dao.EmptyResultDataAccessException;
18 import org.springframework.data.domain.Page;
19 import org.springframework.data.domain.Pageable;
20 import org.springframework.util.Assert; 19 import org.springframework.util.Assert;
21 import com.topdraw.utils.PageUtil;
22 import com.topdraw.utils.QueryHelp;
23 20
24 import java.util.List;
25 import java.util.Map;
26 import java.util.Objects; 21 import java.util.Objects;
27 import java.util.Optional; 22 import java.util.Optional;
28 23
...@@ -34,106 +29,141 @@ import java.util.Optional; ...@@ -34,106 +29,141 @@ import java.util.Optional;
34 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) 29 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
35 public class UserTvServiceImpl implements UserTvService { 30 public class UserTvServiceImpl implements UserTvService {
36 31
37 @Autowired
38 private UserTvRepository UserTvRepository;
39 32
40 @Autowired 33 @Autowired
41 private UserTvMapper UserTvMapper; 34 private UserTvMapper userTvMapper;
42
43 @Autowired 35 @Autowired
44 private MemberService memberService; 36 private MemberService memberService;
45 37 @Autowired
38 private UserTvRepository userTvRepository;
39
40 /**
41 * 获取大屏账户对应的会员
42 * <Waring>
43 * 如果绑定了小屏,则获取对应主账号对应的会员信息,如果没有绑定小屏会员则默认获取大屏自己的会员(x_member)
44 * </Waring>
45 * @param platformAccount
46 * @return
47 */
46 @Override 48 @Override
47 public Map<String, Object> queryAll(UserTvQueryCriteria criteria, Pageable pageable) { 49 public MemberDTO findMemberByPlatformAccount(String platformAccount){
48 Page<UserTv> page = UserTvRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); 50 // 大屏账户
49 return PageUtil.toPage(page.map(UserTvMapper::toDto)); 51 UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount);
52
53 if (Objects.nonNull(userTvDTO)) {
54
55 // 主账号会员code
56 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
57 if (StringUtils.isNotBlank(platformAccount))
58 return this.findMemberByMemberCode(priorityMemberCode);
59 else
60 return this.findMemberByMemberId(userTvDTO.getMemberId());
61
62 }
63
64 throw new EntityNotFoundException(UserTvDTO.class,"platformAccount", GlobeExceptionMsg.IPTV_IS_NULL);
50 } 65 }
51 66
52 @Override 67 private MemberDTO findMemberByMemberCode(String memberCode) {
53 public List<UserTvDTO> queryAll(UserTvQueryCriteria criteria) { 68 return this.memberService.findByCode(memberCode);
54 return UserTvMapper.toDto(UserTvRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); 69 }
70
71 private MemberDTO findMemberByMemberId(Long memberId) {
72 return this.memberService.findById(memberId);
55 } 73 }
56 74
57 @Override 75 @Override
58 public UserTvDTO findById(Long id) { 76 public UserTvDTO findById(Long id) {
59 UserTv UserTv = UserTvRepository.findById(id).orElseGet(UserTv::new); 77 UserTv UserTv = this.userTvRepository.findById(id).orElseGet(UserTv::new);
60 ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); 78 ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id);
61 return UserTvMapper.toDto(UserTv); 79 return this.userTvMapper.toDto(UserTv);
62 } 80 }
63 81
64 @Override 82 @Override
65 @Transactional(rollbackFor = Exception.class) 83 @Transactional(rollbackFor = Exception.class)
66 @AsyncMqSend 84 public UserTv create(UserTv resources) {
67 public Long create(UserTv resources) {
68 MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode()); 85 MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode());
69 if (Objects.nonNull(memberDTO)) { 86 if (Objects.nonNull(memberDTO)) {
70 Long id = memberDTO.getId(); 87 Long id = memberDTO.getId();
71 resources.setMemberId(id); 88 resources.setMemberId(id);
72 UserTvRepository.save(resources); 89 this.userTvRepository.save(resources);
73 return resources.getId(); 90 return resources;
74 } 91 }
75 return null; 92 return null;
76 } 93 }
77 94
78 @Override 95 @Override
79 @Transactional(rollbackFor = Exception.class) 96 @Transactional(rollbackFor = Exception.class)
80 @AsyncMqSend
81 public void update(UserTv resources) { 97 public void update(UserTv resources) {
82 UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new); 98 UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new);
83 ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); 99 ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId());
84 UserTv.copy(resources); 100 UserTv.copy(resources);
85 UserTvRepository.save(UserTv); 101 this.userTvRepository.save(UserTv);
86 } 102 }
87 103
88 @Override 104 @Override
89 @Transactional(rollbackFor = Exception.class) 105 @Transactional(rollbackFor = Exception.class)
90 @AsyncMqSend
91 public void unbindPriorityMemberCode(UserTv resources) { 106 public void unbindPriorityMemberCode(UserTv resources) {
92 UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new); 107 UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new);
93 ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); 108 ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId());
94 UserTv.copy(resources); 109 UserTv.copy(resources);
95 UserTvRepository.save(UserTv); 110 this.userTvRepository.save(UserTv);
96 } 111 }
97 112
98 @Override 113 @Override
99 @Transactional(rollbackFor = Exception.class) 114 @Transactional(rollbackFor = Exception.class)
100 @AsyncMqSend
101 public void delete(Long id) { 115 public void delete(Long id) {
102 Assert.notNull(id, "The given id must not be null!"); 116 Assert.notNull(id, "The given id must not be null!");
103 UserTv UserTv = UserTvRepository.findById(id).orElseThrow( 117 UserTv UserTv = this.userTvRepository.findById(id).orElseThrow(
104 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserTv.class, id), 1)); 118 () -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserTv.class, id), 1));
105 UserTvRepository.delete(UserTv); 119 this.userTvRepository.delete(UserTv);
106 } 120 }
107 121
108 @Override 122 @Override
109 public UserTvDTO findByPlatformAccount(String platformAccount) { 123 public UserTvDTO findByPlatformAccount(String platformAccount) {
110 Optional<UserTv> userTv = UserTvRepository.findByPlatformAccount(platformAccount); 124 Optional<UserTv> userTv = this.userTvRepository.findByPlatformAccount(platformAccount);
111 if (userTv.isPresent()) { 125 if (userTv.isPresent()) {
112 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); 126 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
113 return UserTvMapper.toDto(userTv.get()); 127 return this.userTvMapper.toDto(userTv.get());
114 } 128 }
115 return null; 129 return null;
116 } 130 }
117 131
118 @Override 132 @Override
119 public UserTvDTO findByPriorityMemberCode(String memberCode) { 133 public UserTvDTO findByPriorityMemberCode(String memberCode) {
120 Optional<UserTv> userTv = UserTvRepository.findByPriorityMemberCode(memberCode); 134 Optional<UserTv> userTv = this.userTvRepository.findByPriorityMemberCode(memberCode);
121 if (userTv.isPresent()) { 135 if (userTv.isPresent()) {
122 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); 136 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
123 return UserTvMapper.toDto(userTv.get()); 137 return this.userTvMapper.toDto(userTv.get());
124 } 138 }
125 return null; 139 return null;
126 } 140 }
127 141
128 @Override 142 @Override
129 public UserTvDTO findByMemberId(Long memberId) { 143 public UserTvDTO findByMemberId(Long memberId) {
130 Optional<UserTv> userTv = UserTvRepository.findByMemberId(memberId); 144 Optional<UserTv> userTv = this.userTvRepository.findByMemberId(memberId);
131 if (userTv.isPresent()) { 145 if (userTv.isPresent()) {
132 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); 146 ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId());
133 return UserTvMapper.toDto(userTv.get()); 147 return this.userTvMapper.toDto(userTv.get());
134 } 148 }
135 return null; 149 return null;
136 } 150 }
137 151
152 @Override
153 public boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode) {
154 // 检查会员是否存在
155 this.checkMember(memberId, memberCode);
156 //
157 UserTvDTO userTvDTO = this.findByPriorityMemberCode(memberCode);
158 if (Objects.nonNull(userTvDTO)) {
159 return true;
160 }
161 return false;
162 }
163
164 private void checkMember(Long memberId, String memberCode){
165 this.memberService.checkMember(memberId, memberCode);
166 }
167
138 168
139 } 169 }
......
1 package com.topdraw.business.module.user.weixin.domain; 1 package com.topdraw.business.module.user.weixin.domain;
2 2
3 import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; 3 import com.topdraw.business.module.common.domain.AsyncMqModule;
4 import com.topdraw.business.module.common.validated.CreateGroup;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.experimental.Accessors; 6 import lombok.experimental.Accessors;
6 import cn.hutool.core.bean.BeanUtil; 7 import cn.hutool.core.bean.BeanUtil;
7 import cn.hutool.core.bean.copier.CopyOptions; 8 import cn.hutool.core.bean.copier.CopyOptions;
8 import javax.persistence.*; 9 import javax.persistence.*;
10 import javax.validation.constraints.NotNull;
11
9 import org.springframework.data.annotation.CreatedDate; 12 import org.springframework.data.annotation.CreatedDate;
10 import org.springframework.data.annotation.LastModifiedDate; 13 import org.springframework.data.annotation.LastModifiedDate;
11 import org.springframework.data.jpa.domain.support.AuditingEntityListener; 14 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
...@@ -22,7 +25,7 @@ import java.io.Serializable; ...@@ -22,7 +25,7 @@ import java.io.Serializable;
22 @EntityListeners(AuditingEntityListener.class) 25 @EntityListeners(AuditingEntityListener.class)
23 @Accessors(chain = true) 26 @Accessors(chain = true)
24 @Table(name="uc_user_weixin") 27 @Table(name="uc_user_weixin")
25 public class UserWeixin extends DefaultAsyncMqModule implements Serializable { 28 public class UserWeixin extends AsyncMqModule implements Serializable {
26 29
27 // ID 30 // ID
28 @Id 31 @Id
...@@ -36,14 +39,17 @@ public class UserWeixin extends DefaultAsyncMqModule implements Serializable { ...@@ -36,14 +39,17 @@ public class UserWeixin extends DefaultAsyncMqModule implements Serializable {
36 39
37 // 微信unionid,针对开发者 40 // 微信unionid,针对开发者
38 @Column(name = "unionid") 41 @Column(name = "unionid")
42 @NotNull(message = "unionid can't be null",groups = {CreateGroup.class})
39 private String unionid; 43 private String unionid;
40 44
41 // 微信appid 45 // 微信appid
42 @Column(name = "appid") 46 @Column(name = "appid")
47 @NotNull(message = "appid can't be null",groups = {CreateGroup.class})
43 private String appid; 48 private String appid;
44 49
45 // 微信openid,针对微信app 50 // 微信openid,针对微信app
46 @Column(name = "openid") 51 @Column(name = "openid")
52 @NotNull(message = "openid can't be null",groups = {CreateGroup.class})
47 private String openid; 53 private String openid;
48 54
49 // 关注状态 0 -未关注 1 - 已关注 55 // 关注状态 0 -未关注 1 - 已关注
......
1 package com.topdraw.business.module.user.weixin.domain;
2
3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.exception.BadRequestException;
5 import com.topdraw.exception.GlobeExceptionMsg;
6 import com.topdraw.util.TimestampUtil;
7 import org.apache.commons.lang3.StringUtils;
8
9 import java.sql.Timestamp;
10 import java.util.Objects;
11
12 /**
13 * @author :
14 * @description:
15 * @function :
16 * @date :Created in 2022/3/14 17:02
17 * @version: :
18 * @modified By:
19 * @since : modified in 2022/3/14 17:02
20 */
21 public class UserWeixinBuilder {
22
23 public static UserWeixin build(Long memberId,String appId,String openId,String unionId,String nickname,String headimgurl){
24 UserWeixin userWeixin = new UserWeixin();
25 userWeixin.setAppid(appId);
26 userWeixin.setOpenid(openId);
27 userWeixin.setUnionid(unionId);
28 userWeixin.setNickname(nickname);
29 userWeixin.setHeadimgurl(headimgurl);
30 return build(memberId,userWeixin);
31 }
32
33 public static UserWeixin build(Long memberId,String appId,String openId,String unionId){
34 UserWeixin userWeixin = new UserWeixin();
35 userWeixin.setAppid(appId);
36 userWeixin.setOpenid(openId);
37 userWeixin.setUnionid(unionId);
38 return build(memberId,userWeixin);
39 }
40
41 public static UserWeixin build(UserWeixin userWeixin){
42 return build(userWeixin.getId(),
43 userWeixin.getMemberId(),
44 userWeixin.getUnionid(),userWeixin.getAppid(),userWeixin.getOpenid(),
45 userWeixin.getStatus(),userWeixin.getSyncStatus(),
46 userWeixin.getNickname(),userWeixin.getHeadimgurl(),
47 userWeixin.getPrivilege(), userWeixin.getRefreshToken(),userWeixin.getAccessToken(),
48 userWeixin.getExpiresIn(),userWeixin.getExpiresTime(),userWeixin.getDescription(),
49 userWeixin.getCreateBy(),userWeixin.getUpdateBy(),userWeixin.getSourceType(),userWeixin.getSourceId(),
50 userWeixin.getSourceDesc(),userWeixin.getSourceUser(),userWeixin.getSourceEntity(),userWeixin.getCountry(),userWeixin.getProvince(),
51 userWeixin.getCity(),userWeixin.getSex());
52 }
53
54
55 public static UserWeixin build(Long memberId , UserWeixin userWeixin){
56 return build(userWeixin.getId(),
57 memberId,
58 userWeixin.getUnionid(),userWeixin.getAppid(),userWeixin.getOpenid(),
59 userWeixin.getStatus(),userWeixin.getSyncStatus(),
60 userWeixin.getNickname(),userWeixin.getHeadimgurl(),
61 userWeixin.getPrivilege(), userWeixin.getRefreshToken(),userWeixin.getAccessToken(),
62 userWeixin.getExpiresIn(),userWeixin.getExpiresTime(),userWeixin.getDescription(),
63 userWeixin.getCreateBy(),userWeixin.getUpdateBy(),userWeixin.getSourceType(),userWeixin.getSourceId(),
64 userWeixin.getSourceDesc(),userWeixin.getSourceUser(),userWeixin.getSourceEntity(),userWeixin.getCountry(),userWeixin.getProvince(),
65 userWeixin.getCity(),userWeixin.getSex());
66 }
67
68 public static UserWeixin build(Member member , UserWeixin userWeixin) {
69 return build(userWeixin.getId(),
70 member.getId(),
71 userWeixin.getUnionid(),userWeixin.getAppid(),userWeixin.getOpenid(),
72 userWeixin.getStatus(),userWeixin.getSyncStatus(),
73 userWeixin.getNickname(),userWeixin.getHeadimgurl(),
74 userWeixin.getPrivilege(), userWeixin.getRefreshToken(),userWeixin.getAccessToken(),
75 userWeixin.getExpiresIn(),userWeixin.getExpiresTime(),userWeixin.getDescription(),
76 userWeixin.getCreateBy(),userWeixin.getUpdateBy(),userWeixin.getSourceType(),userWeixin.getSourceId(),
77 userWeixin.getSourceDesc(),userWeixin.getSourceUser(),userWeixin.getSourceEntity(),userWeixin.getCountry(),userWeixin.getProvince(),
78 userWeixin.getCity(),userWeixin.getSex());
79 }
80
81
82 public static UserWeixin build(Long id ,
83 Long memberId,
84 String unionId, String appId,String openId,
85 Integer status, Integer syncStatus,
86 String nickname,String headimgurl,
87 String privilege,String refreshToken,
88 String accessToken,Integer expiresIn,Timestamp expiresTime,String description,
89 String createBy,String updateBy,
90 String sourceType,String sourceId,
91 String sourceDesc,
92 Long sourceUser,String sourceEntity,
93 String country,String province,String city,
94 Integer sex){
95
96 if (Objects.isNull(memberId)) {
97 throw new BadRequestException(GlobeExceptionMsg.MEMBER_ID_IS_NULL);
98 }
99
100 UserWeixin userWeixin = new UserWeixin();
101 userWeixin.setId(Objects.nonNull(id)?id:null);
102 userWeixin.setMemberId(memberId);
103 userWeixin.setUnionid(StringUtils.isNotBlank(unionId)?unionId:"");
104 userWeixin.setAppid(StringUtils.isNotBlank(appId)?appId:"");
105 userWeixin.setOpenid(StringUtils.isNotBlank(openId)?openId:"");
106 userWeixin.setStatus(Objects.nonNull(status)?status:0);
107 userWeixin.setSyncStatus(Objects.nonNull(syncStatus)?syncStatus:0);
108 userWeixin.setNickname(StringUtils.isNotBlank(nickname)?nickname:"");
109 userWeixin.setHeadimgurl(StringUtils.isNotBlank(headimgurl)?headimgurl:"");
110 userWeixin.setPrivilege(StringUtils.isNotBlank(privilege)?privilege:"");
111 userWeixin.setRefreshToken(StringUtils.isNotBlank(refreshToken)?refreshToken:"");
112 userWeixin.setAccessToken(StringUtils.isNotBlank(accessToken)?accessToken:"");
113 userWeixin.setExpiresIn(expiresIn);
114 userWeixin.setExpiresTime(expiresTime);
115 userWeixin.setDescription(StringUtils.isNotBlank(description)?description:"");
116 userWeixin.setCreateBy(StringUtils.isNotBlank(createBy)?createBy:"system");
117 userWeixin.setUpdateBy(StringUtils.isNotBlank(updateBy)?updateBy:"system");
118 userWeixin.setSourceType(StringUtils.isNotBlank(sourceType)?sourceType:"");
119 userWeixin.setSourceId(StringUtils.isNotBlank(sourceId)?sourceId:"");
120 userWeixin.setSourceDesc(StringUtils.isNotBlank(sourceDesc)?sourceId:"");
121 userWeixin.setSourceUser(Objects.nonNull(sourceUser)?sourceUser:0L);
122 userWeixin.setSourceEntity(StringUtils.isNotBlank(sourceEntity)?sourceEntity:"");
123 userWeixin.setAuthTime(TimestampUtil.now());
124 userWeixin.setCountry(StringUtils.isNotBlank(country)?country:"");
125 userWeixin.setProvince(StringUtils.isNotBlank(province)?province:"");
126 userWeixin.setCity(StringUtils.isNotBlank(city)?city:"");
127 userWeixin.setSex(Objects.nonNull(sex)?sex:-1);
128 return userWeixin;
129 }
130
131 }
...@@ -4,7 +4,6 @@ import com.topdraw.annotation.AnonymousAccess; ...@@ -4,7 +4,6 @@ import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.common.ResultInfo; 4 import com.topdraw.common.ResultInfo;
5 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 5 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
6 import com.topdraw.business.module.user.weixin.service.UserWeixinService; 6 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
7 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.data.domain.Pageable; 8 import org.springframework.data.domain.Pageable;
10 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
...@@ -22,19 +21,7 @@ public class UserWeixinController { ...@@ -22,19 +21,7 @@ public class UserWeixinController {
22 21
23 @Autowired 22 @Autowired
24 private UserWeixinService UserWeixinService; 23 private UserWeixinService UserWeixinService;
25 24
26 @GetMapping
27 @ApiOperation("查询UserWeixin")
28 public ResultInfo getUserWeixins(UserWeixinQueryCriteria criteria, Pageable pageable) {
29 return ResultInfo.successPage(UserWeixinService.queryAll(criteria,pageable));
30 }
31
32 @GetMapping(value = "/all")
33 @ApiOperation("查询所有UserWeixin")
34 public ResultInfo getUserWeixins(UserWeixinQueryCriteria criteria) {
35 return ResultInfo.success(UserWeixinService.queryAll(criteria));
36 }
37
38 @PostMapping(value = "/create") 25 @PostMapping(value = "/create")
39 @ApiOperation("新增UserWeixin") 26 @ApiOperation("新增UserWeixin")
40 @AnonymousAccess 27 @AnonymousAccess
......
...@@ -2,11 +2,6 @@ package com.topdraw.business.module.user.weixin.service; ...@@ -2,11 +2,6 @@ package com.topdraw.business.module.user.weixin.service;
2 2
3 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 3 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
4 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 4 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
5 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
6 import org.springframework.data.domain.Pageable;
7 import java.util.Map;
8 import java.util.List;
9 import java.util.Optional;
10 5
11 /** 6 /**
12 * @author XiangHan 7 * @author XiangHan
...@@ -15,21 +10,6 @@ import java.util.Optional; ...@@ -15,21 +10,6 @@ import java.util.Optional;
15 public interface UserWeixinService { 10 public interface UserWeixinService {
16 11
17 /** 12 /**
18 * 查询数据分页
19 * @param criteria 条件参数
20 * @param pageable 分页参数
21 * @return Map<String,Object>
22 */
23 Map<String,Object> queryAll(UserWeixinQueryCriteria criteria, Pageable pageable);
24
25 /**
26 * 查询所有数据不分页
27 * @param criteria 条件参数
28 * @return List<UserWeixinDTO>
29 */
30 List<UserWeixinDTO> queryAll(UserWeixinQueryCriteria criteria);
31
32 /**
33 * 根据ID查询 13 * 根据ID查询
34 * @param id ID 14 * @param id ID
35 * @return UserWeixinDTO 15 * @return UserWeixinDTO
......
...@@ -2,25 +2,18 @@ package com.topdraw.business.module.user.weixin.service.impl; ...@@ -2,25 +2,18 @@ package com.topdraw.business.module.user.weixin.service.impl;
2 2
3 import com.topdraw.aspect.AsyncMqSend; 3 import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 4 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
5 import com.topdraw.business.module.user.weixin.domain.UserWeixinBuilder;
5 import com.topdraw.utils.ValidationUtil; 6 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository; 7 import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
7 import com.topdraw.business.module.user.weixin.service.UserWeixinService; 8 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
8 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 9 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
9 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
10 import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper; 10 import com.topdraw.business.module.user.weixin.service.mapper.UserWeixinMapper;
11 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
14 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
15 import org.springframework.dao.EmptyResultDataAccessException; 15 import org.springframework.dao.EmptyResultDataAccessException;
16 import org.springframework.data.domain.Page;
17 import org.springframework.data.domain.Pageable;
18 import org.springframework.util.Assert; 16 import org.springframework.util.Assert;
19 import com.topdraw.utils.PageUtil;
20 import com.topdraw.utils.QueryHelp;
21
22 import java.util.List;
23 import java.util.Map;
24 17
25 /** 18 /**
26 * @author XiangHan 19 * @author XiangHan
...@@ -37,17 +30,6 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -37,17 +30,6 @@ public class UserWeixinServiceImpl implements UserWeixinService {
37 private UserWeixinMapper UserWeixinMapper; 30 private UserWeixinMapper UserWeixinMapper;
38 31
39 @Override 32 @Override
40 public Map<String, Object> queryAll(UserWeixinQueryCriteria criteria, Pageable pageable) {
41 Page<UserWeixin> page = UserWeixinRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
42 return PageUtil.toPage(page.map(UserWeixinMapper::toDto));
43 }
44
45 @Override
46 public List<UserWeixinDTO> queryAll(UserWeixinQueryCriteria criteria) {
47 return UserWeixinMapper.toDto(UserWeixinRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
48 }
49
50 @Override
51 public UserWeixinDTO findById(Long id) { 33 public UserWeixinDTO findById(Long id) {
52 UserWeixin UserWeixin = UserWeixinRepository.findById(id).orElseGet(UserWeixin::new); 34 UserWeixin UserWeixin = UserWeixinRepository.findById(id).orElseGet(UserWeixin::new);
53 ValidationUtil.isNull(UserWeixin.getId(),"UserWeixin","id",id); 35 ValidationUtil.isNull(UserWeixin.getId(),"UserWeixin","id",id);
...@@ -58,7 +40,8 @@ public class UserWeixinServiceImpl implements UserWeixinService { ...@@ -58,7 +40,8 @@ public class UserWeixinServiceImpl implements UserWeixinService {
58 @Transactional(rollbackFor = Exception.class) 40 @Transactional(rollbackFor = Exception.class)
59 @AsyncMqSend 41 @AsyncMqSend
60 public UserWeixin create(UserWeixin resources) { 42 public UserWeixin create(UserWeixin resources) {
61 UserWeixinRepository.save(resources); 43 UserWeixin build = UserWeixinBuilder.build(resources);
44 UserWeixinRepository.save(build);
62 return resources; 45 return resources;
63 } 46 }
64 47
......
1 package com.topdraw.business.module.weixin.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 pengmengqing
17 * @date 2021-01-28
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_user_weixin__weixin_message_template")
24 public class UserWeixinWeixinMessageTemplate 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 = "user_weixin_id", nullable = false)
34 private Long userWeixinId;
35
36 // 微信消息模板id
37 @Column(name = "weixin_message_template_id", nullable = false)
38 private Long weixinMessageTemplateId;
39
40 // 用户是否订阅: 0-否, 1-是
41 @Column(name = "status", nullable = false)
42 private Integer status;
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(UserWeixinWeixinMessageTemplate source){
55 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
56 }
57 }
1 package com.topdraw.business.module.weixin.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 pengmengqing
17 * @date 2021-01-28
18 */
19 @Entity
20 @Data
21 @EntityListeners(AuditingEntityListener.class)
22 @Accessors(chain = true)
23 @Table(name="uc_weixin_message_template")
24 public class WeixinMessageTemplate implements Serializable {
25
26 // ID
27 @Id
28 @GeneratedValue(strategy = GenerationType.IDENTITY)
29 @Column(name = "id")
30 private Long id;
31
32 // 标识 order-下单成功通知,cancellation-核销成功通知
33 @Column(name = "code", nullable = false)
34 private String code;
35
36 // 微信appid
37 @Column(name = "appid", nullable = false)
38 private String appid;
39
40 // 微信模板id
41 @Column(name = "template_id", nullable = false)
42 private String templateId;
43
44 // 状态:0-无效,1-有效
45 @Column(name = "status", nullable = false)
46 private Integer status;
47
48 // 描述
49 @Column(name = "description")
50 private String description;
51
52 // 创建时间
53 @CreatedDate
54 @Column(name = "create_time")
55 private Timestamp createTime;
56
57 // 更新时间
58 @LastModifiedDate
59 @Column(name = "update_time")
60 private Timestamp updateTime;
61
62 public void copy(WeixinMessageTemplate source){
63 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
64 }
65 }
1 package com.topdraw.business.module.weixin.repository;
2
3 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
7
8 /**
9 * @author pengmengqing
10 * @date 2021-01-28
11 */
12 public interface UserWeixinWeixinMessageTemplateRepository extends JpaRepository<UserWeixinWeixinMessageTemplate, Long>, JpaSpecificationExecutor<UserWeixinWeixinMessageTemplate> {
13
14 }
1 package com.topdraw.business.module.weixin.repository;
2
3
4 import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
5 import org.springframework.data.jpa.repository.JpaRepository;
6 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7
8 import java.util.Optional;
9
10 /**
11 * @author pengmengqing
12 * @date 2021-01-28
13 */
14 public interface WeixinMessageTemplateRepository extends JpaRepository<WeixinMessageTemplate, Long>, JpaSpecificationExecutor<WeixinMessageTemplate> {
15
16 Optional<WeixinMessageTemplate> findFirstByCode(String code);
17
18 Optional<WeixinMessageTemplate> findFirstByCodeAndAppid(String code, String appid);
19
20 Optional<WeixinMessageTemplate> findFirstByTemplateId(String templateId);
21 }
1 package com.topdraw.business.module.weixin.rest;
2
3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService;
5 import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
6 import com.topdraw.common.ResultInfo;
7 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.web.bind.annotation.PostMapping;
11 import org.springframework.web.bind.annotation.RequestBody;
12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RestController;
14
15 import java.util.ArrayList;
16
17 /**
18 * @author pengmengqing
19 * @date 2021-01-28
20 */
21 @Api(tags = "UserWeixinWeixinMessageTemplate管理")
22 @RestController
23 @RequestMapping("/ucEngine/api/UserWeixinWeixinMessageTemplate")
24 public class UserWeixinWeixinMessageTemplateController {
25
26 @Autowired
27 private UserWeixinWeixinMessageTemplateService userWeixinWeixinMessageTemplateService;
28
29 @AnonymousAccess
30 @PostMapping
31 @ApiOperation("新增或修改MemberWeixinMessageTemplate")
32 public ResultInfo createOrUpdate(@RequestBody UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) {
33 userWeixinWeixinMessageTemplateService.createOrUpdate(criteria);
34 return ResultInfo.success(new ArrayList<>());
35 }
36
37 }
1 package com.topdraw.business.module.weixin.service;
2
3
4 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
6 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
7 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria;
8 import org.springframework.data.domain.Pageable;
9
10 import javax.servlet.http.HttpServletResponse;
11 import java.io.IOException;
12 import java.util.List;
13 import java.util.Map;
14
15 /**
16 * @author pengmengqing
17 * @date 2021-01-28
18 */
19 public interface UserWeixinWeixinMessageTemplateService {
20
21 void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria);
22 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import lombok.Data;
4
5 import java.util.List;
6
7 @Data
8 public class UpdateUserWeixinWeixinMessageTemplateQueryCriteria {
9 private Long memberId;
10
11 private List<UserWeixinWeixinMessageTemplateQueryCriteria> templateList;
12
13 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6 import java.sql.Timestamp;
7
8
9 /**
10 * @author pengmengqing
11 * @date 2021-01-28
12 */
13 @Data
14 public class UserWeixinWeixinMessageTemplateDTO implements Serializable {
15
16 // ID
17 private Long id;
18
19 // 用户id
20 private Long userWeixinId;
21
22 // 微信消息模板id
23 private Long weixinMessageTemplateId;
24
25 // 用户是否订阅: 0-否, 1-是
26 private Integer status;
27
28 // 创建时间
29 private Timestamp createTime;
30
31 // 更新时间
32 private Timestamp updateTime;
33 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 /**
7 * @author pengmengqing
8 * @date 2021-01-28
9 */
10 @Data
11 public class UserWeixinWeixinMessageTemplateQueryCriteria {
12 // 用户id
13 @Query(propName = "userWeixinId")
14 private Long memberId;
15
16 // 微信消息模板id
17 @Query
18 private Long weixinMessageTemplateId;
19
20 // 用户是否订阅: 0-否, 1-是
21 @Query
22 private Integer status = 1;
23
24 private String templateId;
25 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import lombok.Data;
4
5 import java.io.Serializable;
6
7
8 /**
9 * @author pengmengqing
10 * @date 2021-01-28
11 */
12 @Data
13 public class WeixinMessageTemplateDTO implements Serializable {
14
15 // ID
16 private Long id;
17
18 // 标识 order-下单成功通知,cancellation-核销成功通知
19 private String code;
20
21 // 微信模板id
22 private String templateId;
23
24 // 描述
25 private String description;
26 }
1 package com.topdraw.business.module.weixin.service.dto;
2
3 import com.topdraw.annotation.Query;
4 import lombok.Data;
5
6 import java.util.List;
7
8 /**
9 * @author pengmengqing
10 * @date 2021-01-28
11 */
12 @Data
13 public class WeixinMessageTemplateQueryCriteria{
14
15 private String codes;
16
17 @Query(propName = "code", type = Query.Type.IN)
18 private List<String> codeList;
19
20 @Query
21 private String appid;
22
23 @Query
24 private Integer status = 1;
25 }
1 package com.topdraw.business.module.weixin.service.impl;
2
3
4 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.domain.WeixinMessageTemplate;
6 import com.topdraw.business.module.weixin.repository.UserWeixinWeixinMessageTemplateRepository;
7 import com.topdraw.business.module.weixin.repository.WeixinMessageTemplateRepository;
8 import com.topdraw.business.module.weixin.service.UserWeixinWeixinMessageTemplateService;
9 import com.topdraw.business.module.weixin.service.dto.UpdateUserWeixinWeixinMessageTemplateQueryCriteria;
10 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
11 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateQueryCriteria;
12 import com.topdraw.business.module.weixin.service.mapper.UserWeixinWeixinMessageTemplateMapper;
13 import com.topdraw.utils.FileUtil;
14 import com.topdraw.utils.PageUtil;
15 import com.topdraw.utils.QueryHelp;
16 import com.topdraw.utils.ValidationUtil;
17 import lombok.extern.slf4j.Slf4j;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.dao.EmptyResultDataAccessException;
20 import org.springframework.data.domain.Page;
21 import org.springframework.data.domain.Pageable;
22 import org.springframework.stereotype.Service;
23 import org.springframework.transaction.annotation.Propagation;
24 import org.springframework.transaction.annotation.Transactional;
25 import org.springframework.util.Assert;
26
27 import javax.servlet.http.HttpServletResponse;
28 import java.io.IOException;
29 import java.util.*;
30
31 /**
32 * @author pengmengqing
33 * @date 2021-01-28
34 */
35 @Service
36 @Slf4j
37 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
38 public class UserWeixinWeixinMessageTemplateServiceImpl implements UserWeixinWeixinMessageTemplateService {
39
40 @Autowired
41 private UserWeixinWeixinMessageTemplateRepository userWeixinWeixinMessageTemplateRepository;
42
43 @Autowired
44 private WeixinMessageTemplateRepository weixinMessageTemplateRepository;
45
46 @Override
47 @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
48 public void createOrUpdate(UpdateUserWeixinWeixinMessageTemplateQueryCriteria criteria) {
49 for (UserWeixinWeixinMessageTemplateQueryCriteria queryCriteria : criteria.getTemplateList()) {
50 queryCriteria.setMemberId(criteria.getMemberId());
51 Integer status = queryCriteria.getStatus();
52 queryCriteria.setStatus(null);
53 String templateId = queryCriteria.getTemplateId();
54 Optional<WeixinMessageTemplate> templateOptional = weixinMessageTemplateRepository.findFirstByTemplateId(templateId);
55 if (!templateOptional.isPresent()) {
56 log.info("template " + templateId + " not exist");
57 continue;
58 }
59 Long id = templateOptional.get().getId();
60 queryCriteria.setWeixinMessageTemplateId(id);
61 Optional<UserWeixinWeixinMessageTemplate> optional = userWeixinWeixinMessageTemplateRepository.findOne(((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, queryCriteria, criteriaBuilder)));
62 if (!optional.isPresent()) {
63 UserWeixinWeixinMessageTemplate userWeixinWeixinMessageTemplate = new UserWeixinWeixinMessageTemplate();
64 userWeixinWeixinMessageTemplate.setUserWeixinId(queryCriteria.getMemberId())
65 .setWeixinMessageTemplateId(queryCriteria.getWeixinMessageTemplateId())
66 .setStatus(status);
67 userWeixinWeixinMessageTemplateRepository.save(userWeixinWeixinMessageTemplate);
68 } else {
69 UserWeixinWeixinMessageTemplate UserWeixinWeixinMessageTemplate = optional.get();
70 if (!status.equals(UserWeixinWeixinMessageTemplate.getStatus())) {
71 UserWeixinWeixinMessageTemplate.setStatus(status);
72 userWeixinWeixinMessageTemplateRepository.save(UserWeixinWeixinMessageTemplate);
73 }
74 }
75 }
76 }
77 }
1 package com.topdraw.business.module.weixin.service.mapper;
2
3 import com.topdraw.base.BaseMapper;
4 import com.topdraw.business.module.weixin.domain.UserWeixinWeixinMessageTemplate;
5 import com.topdraw.business.module.weixin.service.dto.UserWeixinWeixinMessageTemplateDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author pengmengqing
11 * @date 2021-01-28
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface UserWeixinWeixinMessageTemplateMapper extends BaseMapper<UserWeixinWeixinMessageTemplateDTO, UserWeixinWeixinMessageTemplate> {
15
16 }
1 package com.topdraw.business.process.domian; 1 package com.topdraw.business.process.domian;
2 2
3 import com.topdraw.business.module.common.validated.CreateGroup;
3 import lombok.AllArgsConstructor; 4 import lombok.AllArgsConstructor;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.NoArgsConstructor; 6 import lombok.NoArgsConstructor;
...@@ -15,76 +16,76 @@ public class TempIptvUser { ...@@ -15,76 +16,76 @@ public class TempIptvUser {
15 16
16 private String unionid; 17 private String unionid;
17 18
18 // 账户 19 /** 账户 */
19 @Transient 20 @Transient
21 @NotNull(message = "platformAccount can't be null" , groups = {CreateGroup.class})
20 private String platformAccount; 22 private String platformAccount;
21 23
22 // 分数 24 /** 分数 */
23 @Transient 25 @Transient
24 private Long points; 26 private Long points;
25 27
26 28 /** ID */
27 // ID
28 private Long id; 29 private Long id;
29 30
30 // 人ID 31 /** 人ID */
31 private Long personId; 32 private Long personId;
32 33
33 // 运营商平台 34 /** 运营商平台 */
34 private String platform; 35 private String platform;
35 36
36 // 手机号 37 /** 手机号 */
37 private String cellphone; 38 private String cellphone;
38 39
39 // 用户名 40 /** 用户名 */
40 private String username; 41 private String username;
41 42
42 // 密码 MD5 43 /** 密码 MD5 */
43 private String password; 44 private String password;
44 45
45 // 昵称 Base64 46 /** 昵称 Base64 */
46 private String nickname; 47 private String nickname;
47 48
48 // 头像 49 /** 头像 */
49 private String image; 50 private String image;
50 51
51 // 登录天数(总天数) 52 /** 登录天数(总天数) */
52 private Integer loginDays; 53 private Integer loginDays;
53 54
54 // 连续登录天数 55 /** 连续登录天数 */
55 private Integer continueDays; 56 private Integer continueDays;
56 57
57 // 活跃时间 58 /** 活跃时间 */
58 private Timestamp activeTime; 59 private Timestamp activeTime;
59 60
60 // 分组 分组ID用逗号分隔 61 /** 分组 分组ID用逗号分隔 */
61 private String groups; 62 private String groups;
62 63
63 // 标签 标签用逗号分隔 64 /** 标签 标签用逗号分隔 */
64 private String tags; 65 private String tags;
65 66
66 // 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 67 /** 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 */
67 private Integer loginType; 68 private Integer loginType;
68 69
69 // 状态 0-下线 1-上线 70 /** 状态 0-下线 1-上线 */
70 private Integer status; 71 private Integer status;
71 72
72 // 描述 73 /** 描述 */
73 private String description; 74 private String description;
74 75
75 // 创建者 76 /** 创建者 */
76 private String createBy; 77 private String createBy;
77 78
78 // 创建时间 79 /** 创建时间 */
79 private Timestamp createTime; 80 private Timestamp createTime;
80 81
81 // 更新者 82 /** 更新者 */
82 private String updateBy; 83 private String updateBy;
83 84
84 // 更新时间 85 /** 更新时间 */
85 private Timestamp updateTime; 86 private Timestamp updateTime;
86 87
87 // 会员id 88 /** 会员id */
88 private Long memberId; 89 private Long memberId;
89 90
90 private String memberCode; 91 private String memberCode;
......
1 package com.topdraw.business.process.domian; 1 package com.topdraw.business.process.domian.constant;
2 2
3 public enum RightType { 3 public enum RightType {
4 /**积分*/ 4 /**积分*/
......
1 package com.topdraw.business.process.domian.result; 1 package com.topdraw.business.process.domian.constant;
2 2
3 public interface TaskTemplateType { 3 public interface TaskTemplateType {
4 4
......
1 package com.topdraw.business.process.domian; 1 package com.topdraw.business.process.domian.validated;
2 2
3 public interface UnbindGroup { 3 public interface UnbindGroup {
4 } 4 }
......
1 package com.topdraw.business.process.domian.weixin; 1 package com.topdraw.business.process.domian.weixin;
2 2
3
4 import com.alibaba.fastjson.JSONObject;
5 import lombok.Data; 3 import lombok.Data;
6 4
7 @Data 5 @Data
......
...@@ -9,14 +9,11 @@ import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; ...@@ -9,14 +9,11 @@ import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
9 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; 9 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
10 import com.topdraw.business.module.user.weixin.service.UserWeixinService; 10 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
11 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 11 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
12 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
13 import com.topdraw.business.process.domian.weixin.BuyVipBean; 12 import com.topdraw.business.process.domian.weixin.BuyVipBean;
14 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
15 import com.topdraw.business.process.service.MemberOperationService; 13 import com.topdraw.business.process.service.MemberOperationService;
16 import com.topdraw.common.IResultInfo; 14 import com.topdraw.common.IResultInfo;
17 import com.topdraw.common.ResultInfo; 15 import com.topdraw.common.ResultInfo;
18 import com.topdraw.exception.BadRequestException; 16 import com.topdraw.exception.BadRequestException;
19 import com.topdraw.weixin.util.WeChatConstants;
20 import io.swagger.annotations.Api; 17 import io.swagger.annotations.Api;
21 import io.swagger.annotations.ApiOperation; 18 import io.swagger.annotations.ApiOperation;
22 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -14,7 +14,7 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService; ...@@ -14,7 +14,7 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService;
14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
15 import com.topdraw.business.process.domian.TempCustomPointBean; 15 import com.topdraw.business.process.domian.TempCustomPointBean;
16 import com.topdraw.business.process.domian.TempPoints; 16 import com.topdraw.business.process.domian.TempPoints;
17 import com.topdraw.business.process.domian.result.CustomPointsResult; 17 import com.topdraw.business.process.service.dto.CustomPointsResult;
18 import com.topdraw.business.process.service.PointsOperationService; 18 import com.topdraw.business.process.service.PointsOperationService;
19 import com.topdraw.common.ResultInfo; 19 import com.topdraw.common.ResultInfo;
20 import com.topdraw.config.LocalConstants; 20 import com.topdraw.config.LocalConstants;
......
...@@ -3,6 +3,7 @@ package com.topdraw.business.process.rest; ...@@ -3,6 +3,7 @@ package com.topdraw.business.process.rest;
3 import com.topdraw.annotation.AnonymousAccess; 3 import com.topdraw.annotation.AnonymousAccess;
4 import com.topdraw.business.process.domian.TempIptvUser; 4 import com.topdraw.business.process.domian.TempIptvUser;
5 import com.topdraw.business.process.service.TaskOperationService; 5 import com.topdraw.business.process.service.TaskOperationService;
6 import com.topdraw.business.process.service.dto.TaskOperationQueryCriteria;
6 import com.topdraw.common.ResultInfo; 7 import com.topdraw.common.ResultInfo;
7 import io.swagger.annotations.Api; 8 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation; 9 import io.swagger.annotations.ApiOperation;
......
...@@ -3,9 +3,7 @@ package com.topdraw.business.process.service; ...@@ -3,9 +3,7 @@ package com.topdraw.business.process.service;
3 import com.topdraw.business.module.member.domain.Member; 3 import com.topdraw.business.module.member.domain.Member;
4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; 4 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
5 import com.topdraw.business.module.member.service.dto.MemberDTO; 5 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
7 import com.topdraw.business.process.domian.weixin.BuyVipBean; 6 import com.topdraw.business.process.domian.weixin.BuyVipBean;
8 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
9 7
10 public interface MemberOperationService { 8 public interface MemberOperationService {
11 9
......
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.process.domian.TempPoints; 3 import com.topdraw.business.process.domian.TempPoints;
4 import com.topdraw.business.process.domian.result.CustomPointsResult; 4 import com.topdraw.business.process.service.dto.CustomPointsResult;
5 5
6 import java.util.List; 6 import java.util.List;
7 7
......
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.topdraw.business.module.rights.history.domain.RightsHistory; 3 import com.topdraw.business.module.rights.history.domain.RightsHistory;
4 import com.topdraw.business.process.domian.RightType; 4 import com.topdraw.business.process.domian.constant.RightType;
5 5
6 import java.util.List; 6 import java.util.List;
7 import java.util.Map; 7 import java.util.Map;
......
1 package com.topdraw.business.process.service; 1 package com.topdraw.business.process.service;
2 2
3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.module.member.profile.domain.MemberProfile;
5 import com.topdraw.business.module.member.service.dto.MemberDTO; 3 import com.topdraw.business.module.member.service.dto.MemberDTO;
6 import com.topdraw.business.module.user.iptv.domain.UserTv; 4 import com.topdraw.business.module.user.iptv.domain.UserTv;
7 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 5 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
8 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 6 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
9 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 7 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
10 import com.topdraw.business.process.domian.weixin.BindBean; 8 import com.topdraw.business.process.domian.weixin.BindBean;
11 import com.topdraw.business.process.domian.weixin.BuyVipBean;
12 import com.topdraw.business.process.domian.weixin.SubscribeBean; 9 import com.topdraw.business.process.domian.weixin.SubscribeBean;
13 import com.topdraw.business.process.domian.weixin.WeiXinUserBean; 10 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
14 11
15 import java.util.List;
16 import java.util.Map;
17 12
18 public interface UserOperationService { 13 public interface UserOperationService {
19 14
...@@ -22,20 +17,20 @@ public interface UserOperationService { ...@@ -22,20 +17,20 @@ public interface UserOperationService {
22 * @param resources 17 * @param resources
23 * @return 18 * @return
24 */ 19 */
25 boolean createMemberByUserTv(UserTv resources); 20 boolean createTvUserAndCreateMember(UserTv resources);
26 21
27 /** 22 /**
28 * 大屏解绑 23 * 保存小屏账户并创建会员
29 * @param userTv 24 * @param resources
25 * @return
30 */ 26 */
31 void unbind(UserTv userTv); 27 UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources);
32 28
33 /** 29 /**
34 * 30 * 大屏解绑
35 * @param userTv 31 * @param userTv
36 * @param unionId
37 */ 32 */
38 void unbindByUnionId(UserTv userTv,String unionId); 33 void unbind(UserTv userTv);
39 34
40 /** 35 /**
41 * 大屏切换主账户(会员) 36 * 大屏切换主账户(会员)
...@@ -44,13 +39,6 @@ public interface UserOperationService { ...@@ -44,13 +39,6 @@ public interface UserOperationService {
44 void changeMainAccount(UserTv userTv); 39 void changeMainAccount(UserTv userTv);
45 40
46 /** 41 /**
47 *
48 * @param userTv
49 * @param unionId
50 */
51 void changeMainAccountByUnionId(UserTv userTv,String unionId);
52
53 /**
54 * 微信小程序登录 42 * 微信小程序登录
55 * @param resources 43 * @param resources
56 * @return 44 * @return
...@@ -82,20 +70,6 @@ public interface UserOperationService { ...@@ -82,20 +70,6 @@ public interface UserOperationService {
82 UserWeixinDTO saveUserInfo(String data); 70 UserWeixinDTO saveUserInfo(String data);
83 71
84 /** 72 /**
85 * 获取用户授权并解析、保存用户手机号
86 * @param resources
87 * @return
88 */
89 MemberProfile saveUserWeixinPhone(WeiXinUserBean resources);
90
91 /**
92 *
93 * @param content
94 * @return
95 */
96 boolean sendQrCodeMessage(String content);
97
98 /**
99 * 大屏删除所有收藏 73 * 大屏删除所有收藏
100 * @param content 74 * @param content
101 * @return 75 * @return
...@@ -117,13 +91,6 @@ public interface UserOperationService { ...@@ -117,13 +91,6 @@ public interface UserOperationService {
117 boolean addCollection(String content); 91 boolean addCollection(String content);
118 92
119 /** 93 /**
120 * 获取大屏绑定的小屏会员列表
121 * @param platformAccount
122 * @return
123 */
124 List<MemberDTO> findBindByPlatformAccount(String platformAccount);
125
126 /**
127 * 服务号(H5)登录 94 * 服务号(H5)登录
128 * @param resources 95 * @param resources
129 * @return 96 * @return
...@@ -138,14 +105,27 @@ public interface UserOperationService { ...@@ -138,14 +105,27 @@ public interface UserOperationService {
138 boolean appletBind(BindBean resources); 105 boolean appletBind(BindBean resources);
139 106
140 107
141 JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code);
142
143 UserWeixinDTO createWeixinUserAndCreateMember(UserWeixin resources);
144 108
109 /**
110 *
111 * @param memberCode
112 * @param platformAccount
113 */
145 void bind(String memberCode, String platformAccount); 114 void bind(String memberCode, String platformAccount);
146 115
116 /**
117 *
118 * @param memberDTO
119 * @param userTvDTO
120 */
147 void bind(MemberDTO memberDTO, UserTvDTO userTvDTO); 121 void bind(MemberDTO memberDTO, UserTvDTO userTvDTO);
148 122
123 /**
124 *
125 * @param memberDTO
126 * @param platformAccount
127 * @return
128 */
149 UserTvDTO bind(MemberDTO memberDTO, String platformAccount); 129 UserTvDTO bind(MemberDTO memberDTO, String platformAccount);
150 130
151 } 131 }
......
1 package com.topdraw.business.process.domian.result; 1 package com.topdraw.business.process.service.dto;
2 2
3 3
4 import lombok.AllArgsConstructor; 4 import lombok.AllArgsConstructor;
......
1 package com.topdraw.business.process.rest; 1 package com.topdraw.business.process.service.dto;
2 2
3 import lombok.Data; 3 import lombok.Data;
4 4
...@@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull; ...@@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
12 @Data 12 @Data
13 public class TaskOperationQueryCriteria { 13 public class TaskOperationQueryCriteria {
14 14
15 @NotNull(message = "【content】 not be null !!!") 15 @NotNull(message = "content not be null !!!")
16 private String content; 16 private String content;
17 17
18 } 18 }
......
...@@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil;
4 import com.topdraw.business.module.member.domain.Member; 4 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.module.member.profile.service.MemberProfileService; 5 import com.topdraw.business.module.member.profile.service.MemberProfileService;
6 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; 6 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
7 import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
8 import com.topdraw.business.module.member.service.MemberService; 7 import com.topdraw.business.module.member.service.MemberService;
9 import com.topdraw.business.module.member.service.dto.MemberDTO; 8 import com.topdraw.business.module.member.service.dto.MemberDTO;
10 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; 9 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
...@@ -12,29 +11,18 @@ import com.topdraw.business.module.member.viphistory.service.MemberVipHistorySer ...@@ -12,29 +11,18 @@ import com.topdraw.business.module.member.viphistory.service.MemberVipHistorySer
12 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 11 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
13 import com.topdraw.business.module.user.weixin.service.UserWeixinService; 12 import com.topdraw.business.module.user.weixin.service.UserWeixinService;
14 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 13 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
15 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
16 import com.topdraw.business.process.domian.weixin.BuyVipBean; 14 import com.topdraw.business.process.domian.weixin.BuyVipBean;
17 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
18 import com.topdraw.business.process.service.MemberOperationService; 15 import com.topdraw.business.process.service.MemberOperationService;
19 import com.topdraw.exception.EntityNotFoundException; 16 import com.topdraw.exception.EntityNotFoundException;
20 import com.topdraw.util.LocalDateTimeUtil;
21 import com.topdraw.util.TimestampUtil;
22 import com.topdraw.utils.StringUtils;
23 import com.topdraw.utils.ValidationUtil;
24 import org.springframework.beans.BeanUtils; 17 import org.springframework.beans.BeanUtils;
25 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 19 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
27 import org.springframework.stereotype.Service; 20 import org.springframework.stereotype.Service;
28 import org.springframework.util.Assert; 21 import org.springframework.util.Assert;
29 22
30 import java.nio.charset.StandardCharsets;
31 import java.time.LocalDateTime; 23 import java.time.LocalDateTime;
32 import java.time.ZoneOffset; 24 import java.time.ZoneOffset;
33 import java.util.Base64;
34 import java.util.Objects; 25 import java.util.Objects;
35 import java.util.Optional;
36
37 import static org.bouncycastle.asn1.x500.style.RFC4519Style.member;
38 26
39 @Service 27 @Service
40 public class MemberOperationServiceImpl implements MemberOperationService { 28 public class MemberOperationServiceImpl implements MemberOperationService {
......
...@@ -12,7 +12,7 @@ import com.topdraw.business.module.points.detail.detailhistory.service.PointsDet ...@@ -12,7 +12,7 @@ import com.topdraw.business.module.points.detail.detailhistory.service.PointsDet
12 import com.topdraw.business.module.points.detail.domain.PointsDetail; 12 import com.topdraw.business.module.points.detail.domain.PointsDetail;
13 import com.topdraw.business.module.points.detail.service.PointsDetailService; 13 import com.topdraw.business.module.points.detail.service.PointsDetailService;
14 import com.topdraw.business.module.points.service.PointsService; 14 import com.topdraw.business.module.points.service.PointsService;
15 import com.topdraw.business.process.domian.result.CustomPointsResult; 15 import com.topdraw.business.process.service.dto.CustomPointsResult;
16 import com.topdraw.business.process.service.MemberOperationService; 16 import com.topdraw.business.process.service.MemberOperationService;
17 import com.topdraw.business.process.service.PointsOperationService; 17 import com.topdraw.business.process.service.PointsOperationService;
18 import com.topdraw.business.process.domian.TempPoints; 18 import com.topdraw.business.process.domian.TempPoints;
...@@ -33,7 +33,6 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -33,7 +33,6 @@ import org.springframework.transaction.annotation.Propagation;
33 import org.springframework.transaction.annotation.Transactional; 33 import org.springframework.transaction.annotation.Transactional;
34 import org.springframework.util.CollectionUtils; 34 import org.springframework.util.CollectionUtils;
35 35
36 import java.sql.Timestamp;
37 import java.time.LocalDateTime; 36 import java.time.LocalDateTime;
38 import java.util.*; 37 import java.util.*;
39 import java.util.stream.Collectors; 38 import java.util.stream.Collectors;
......
...@@ -6,6 +6,7 @@ import com.topdraw.business.module.rights.history.domain.RightsHistory; ...@@ -6,6 +6,7 @@ import com.topdraw.business.module.rights.history.domain.RightsHistory;
6 import com.topdraw.business.module.rights.history.service.RightsHistoryService; 6 import com.topdraw.business.module.rights.history.service.RightsHistoryService;
7 import com.topdraw.business.module.rights.service.RightsService; 7 import com.topdraw.business.module.rights.service.RightsService;
8 import com.topdraw.business.module.rights.service.dto.RightsDTO; 8 import com.topdraw.business.module.rights.service.dto.RightsDTO;
9 import com.topdraw.business.process.domian.constant.RightType;
9 import com.topdraw.business.process.service.CouponOperationService; 10 import com.topdraw.business.process.service.CouponOperationService;
10 import com.topdraw.business.process.service.ExpOperationService; 11 import com.topdraw.business.process.service.ExpOperationService;
11 import com.topdraw.business.process.service.PointsOperationService; 12 import com.topdraw.business.process.service.PointsOperationService;
......
...@@ -6,7 +6,6 @@ import com.topdraw.business.module.coupon.service.CouponService; ...@@ -6,7 +6,6 @@ import com.topdraw.business.module.coupon.service.CouponService;
6 import com.topdraw.business.module.coupon.service.dto.CouponDTO; 6 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
7 import com.topdraw.business.module.member.group.service.MemberGroupService; 7 import com.topdraw.business.module.member.group.service.MemberGroupService;
8 import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO; 8 import com.topdraw.business.module.member.group.service.dto.MemberGroupDTO;
9 import com.topdraw.business.module.member.group.service.dto.MemberGroupQueryCriteria;
10 import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService; 9 import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
11 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO; 10 import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
12 import com.topdraw.business.module.rights.service.RightsService; 11 import com.topdraw.business.module.rights.service.RightsService;
...@@ -20,7 +19,8 @@ import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQuery ...@@ -20,7 +19,8 @@ import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQuery
20 import com.topdraw.business.module.user.iptv.domain.UserTv; 19 import com.topdraw.business.module.user.iptv.domain.UserTv;
21 import com.topdraw.business.module.user.iptv.service.UserTvService; 20 import com.topdraw.business.module.user.iptv.service.UserTvService;
22 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 21 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
23 import com.topdraw.business.process.domian.result.TaskTemplateType; 22 import com.topdraw.business.process.domian.constant.TaskTemplateType;
23 import com.topdraw.business.process.domian.constant.RightType;
24 import com.topdraw.business.process.service.PointsOperationService; 24 import com.topdraw.business.process.service.PointsOperationService;
25 import com.topdraw.business.process.service.RightsOperationService; 25 import com.topdraw.business.process.service.RightsOperationService;
26 import com.topdraw.business.process.service.TaskOperationService; 26 import com.topdraw.business.process.service.TaskOperationService;
...@@ -981,7 +981,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -981,7 +981,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
981 981
982 long l = System.currentTimeMillis(); 982 long l = System.currentTimeMillis();
983 983
984 this.userTvOperationService.createMemberByUserTv(this.checkUserTv(platformAccount)); 984 this.userTvOperationService.createTvUserAndCreateMember(this.checkUserTv(platformAccount));
985 985
986 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); 986 UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
987 if (Objects.nonNull(userTvDTO)) { 987 if (Objects.nonNull(userTvDTO)) {
......
1 package com.topdraw.exception;
2
3 /**
4 * @author :
5 * @description:
6 * @function :
7 * @date :Created in 2022/3/10 17:16
8 * @version: :
9 * @modified By:
10 * @since : modified in 2022/3/10 17:16
11 */
12 public interface GlobeExceptionMsg {
13
14 /**************************************************************/
15 /** 系统 */
16 String OPERATION_FORBID = "operation forbid";
17 String ENTITY_ALREADY_EXISTS = "entity already exists";
18
19 /**************************************************************/
20
21 /** 会员管理 */
22 String MEMBER_CODE_IS_NULL = "memberCode is null";
23 String MEMBER_ID_IS_NULL = "memberId is null";
24 String MEMBER_ID_AND_CODE_ARE_NULL = "memberId and memberCode both null";
25 String MEMBER_INFO_ERROR = "member info is error";
26 String MEMBER_BLOCK_STATUS = "member status is block";
27
28 /**************************************************************/
29
30 /** 账户管理 **/
31 String IPTV_ID_IS_NULL = "iptvId is null";
32 String IPTV_PLATFORM_ACCOUNT_IS_NULL = "platformAccount is null";
33 String IPTV_IS_NULL = "iptv is null";
34
35 }
1 package com.topdraw.resttemplate;
2
3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.module.member.domain.Member;
6 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
7 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.core.env.Environment;
10 import org.springframework.http.ResponseEntity;
11 import org.springframework.http.client.SimpleClientHttpRequestFactory;
12 import org.springframework.stereotype.Component;
13 import org.springframework.web.client.RestTemplate;
14
15 import javax.annotation.PostConstruct;
16 import java.util.Map;
17
18 @Slf4j
19 @Component
20 public class RestTemplateClient {
21
22 private static RestTemplate restTemplate;
23
24 private static String BASE_URL;
25
26 @Autowired
27 private Environment environment;
28
29 @PostConstruct
30 private void init() {
31 BASE_URL = environment.getProperty("api.baseUrl");
32 SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
33 // 设置连接超时
34 factory.setConnectTimeout(5000);
35 // 设置读取超时
36 factory.setReadTimeout(8000);
37 restTemplate = new RestTemplate(factory);
38 }
39
40 public static JSONObject getMemberInfo(Long memberId) {
41 JSONObject resultSet = null;
42 String url = BASE_URL + "/api/member/findById/" + memberId;
43 log.info("request uc : url is " + url + ", memberId is " + memberId);
44 ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
45 if (responseEntity.getStatusCode().is2xxSuccessful()) {
46 String entityBody = responseEntity.getBody();
47 JSONObject jsonObject = JSONObject.parseObject(entityBody);
48 if (jsonObject.getInteger("businessCode").equals(200)) {
49 resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0);
50 }
51 }
52 log.info("uc response: " + resultSet.toJSONString());
53 return resultSet;
54 }
55
56 public static String createMember(Member member) {
57 String entityBody = "";
58 String url = BASE_URL + "/api/member/create";
59 log.info("request uc : url is " + url + ", memberId is " + com.alibaba.fastjson.JSONObject.toJSONString(member));
60 ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, member, String.class);
61 if (responseEntity.getStatusCode().is2xxSuccessful()) {
62 entityBody = responseEntity.getBody();
63
64 }
65 return entityBody;
66 }
67
68 public static String updateMember(Member member) {
69 String entityBody = "";
70 String url = BASE_URL + "/api/member/update";
71 log.info("request uc : url is " + url + ", memberId is " + com.alibaba.fastjson.JSONObject.toJSONString(member));
72 restTemplate.put(url, member);
73
74 return entityBody;
75 }
76
77 public static String createMemberAddress(MemberAddress member) {
78 JSONObject resultSet = null;
79 String url = BASE_URL + "/api/MemberAddress/create";
80 log.info("request uc : url is " + url + ", memberId is " + com.alibaba.fastjson.JSONObject.toJSONString(member));
81 ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, member, String.class);
82 String entityBody = "";
83 if (responseEntity.getStatusCode().is2xxSuccessful()) {
84 entityBody = responseEntity.getBody();
85 }
86 log.info("uc response: " + entityBody);
87 return entityBody;
88 }
89
90 public static void updateMemberAddress(MemberAddress member) {
91 String url = BASE_URL + "/api/MemberAddress/update";
92 log.info("request uc : url is " + url + ", memberId is " + com.alibaba.fastjson.JSONObject.toJSONString(member));
93 restTemplate.put(url, member);
94
95 }
96
97 public static void deleteMemberAddress(Long id) {
98 String url = BASE_URL + "/api/MemberAddress/delete/" + id;
99 log.info("request uc : url is " + url + ", memberId is " + id);
100 restTemplate.delete(url);
101
102 }
103
104 public static JSONObject getMemberProfile(Long memberId) {
105 JSONObject resultSet = null;
106 String url = BASE_URL + "/api/MemberRelatedInfo/getMemberRelatedInfos";
107 log.info("request uc : url is " + url + ", memberId is " + memberId);
108 ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
109 if (responseEntity.getStatusCode().is2xxSuccessful()) {
110 String entityBody = responseEntity.getBody();
111 JSONObject jsonObject = JSONObject.parseObject(entityBody);
112 if (jsonObject.getInteger("businessCode").equals(200)) {
113 resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0);
114 }
115 }
116 log.info("uc response: " + resultSet.toJSONString());
117 return resultSet;
118 }
119
120 public static String getMemberAddress(Map<String, Object> param) {
121 String entityBody = "";
122 String url = BASE_URL + "/api/MemberAddress/pageMemberAddress?page=" + param.get("page") + "&size=" + param.get("size") + "&memberId=" + param.get("memberId");
123 log.info("request uc : url is " + url + ", param is " + param);
124 ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
125 if (responseEntity.getStatusCode().is2xxSuccessful()) {
126 entityBody = responseEntity.getBody();
127 }
128 log.info("uc response: " + entityBody);
129 return entityBody;
130 }
131
132 public static String getMemberRelatedInfo(Map<String, Object> param) {
133 String entityBody = "";
134 String url = BASE_URL + "/api/MemberRelatedInfo/pageMemberRelatedInfos?page=" + param.get("page") + "&size=" + param.get("size") + "&memberId=" + param.get("memberId");
135 log.info("request uc : url is " + url + ", memberId is " + param);
136 ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
137 if (responseEntity.getStatusCode().is2xxSuccessful()) {
138 entityBody = responseEntity.getBody();
139 }
140 log.info("uc response: " + entityBody);
141 return entityBody;
142 }
143
144 public static void deleteMemberRelatedInfo(Long memberRelatedId) {
145 String url = BASE_URL + "/api/MemberRelatedInfo/delete/" + memberRelatedId;
146 log.info("request uc : url is " + url + ", memberId is " + memberRelatedId);
147 restTemplate.delete(url, String.class);
148 }
149
150 public static String addMemberRelatedInfo(MemberRelatedInfo resources) {
151 String entityBody = null;
152 String url = BASE_URL + "/api/MemberRelatedInfo/create";
153 log.info("request uc : url is " + url + ", memberRelatedId is " + com.alibaba.fastjson.JSONObject.toJSONString(resources));
154 ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, resources, String.class);
155 if (responseEntity.getStatusCode().is2xxSuccessful()) {
156 entityBody = responseEntity.getBody();
157 // JSONObject jsonObject = JSONObject.parseObject(entityBody);
158 // if (jsonObject.getInteger("businessCode").equals(200)) {
159 // resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0);
160 // }
161 }
162 log.info("uc response: " + entityBody);
163 return entityBody;
164 }
165
166 public static String updateMemberRelatedInfo(MemberRelatedInfo resources) {
167 String resultSet = "";
168 String url = BASE_URL + "/api/MemberRelatedInfo/update";
169 log.info("request uc : url is " + url + ", memberRelatedId is " + com.alibaba.fastjson.JSONObject.toJSONString(resources));
170 restTemplate.put(url, resources);
171
172 return resultSet;
173 }
174 }
1 package com.topdraw.weixin.applet;
2
3 import cn.hutool.http.HttpUtil;
4 import com.alibaba.fastjson.JSONObject;
5 import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
6 import com.topdraw.security.AESUtil;
7 import com.topdraw.utils.StringUtils;
8 import com.topdraw.weixin.beans.DefaultWeiXinBeanDefinition;
9 import com.topdraw.weixin.beans.WeiXinUserParser;
10 import com.topdraw.weixin.beans.config.WeiXinAppListConfig;
11 import com.topdraw.weixin.util.WeChatConstants;
12 import com.topdraw.weixin.util.WeiXinRequestUtil;
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.beans.factory.annotation.Value;
15 import org.springframework.http.HttpMethod;
16 import org.springframework.http.ResponseEntity;
17 import org.springframework.stereotype.Component;
18 import org.springframework.web.client.RestTemplate;
19
20 import java.util.List;
21 import java.util.Map;
22 import java.util.Optional;
23
24 @Component
25 public class WeiXinAppletUserParser implements WeiXinUserParser {
26
27 @Autowired
28 private WeiXinAppListConfig weiXinAppListConfig;
29
30 @Autowired
31 private WeiXinRequestUtil weixinRequestUtil;
32
33 @Value("${uc.service.platform:}")
34 private String platform;
35
36 @Value("${key:}")
37 private String key;
38
39 @Value("${uc.app.subAppId:wx05f35931270014be}")
40 private String subAppId;
41
42 @Value("${uc.app.h5AppId:wxca962918dfeed88c}")
43 private String h5AppId;
44
45 @Value("${uc.app.appletAppid:wxc57d42de3d351cec}")
46 private String appletAppid;
47
48 @Value("${file.upload:upload}")
49 private String filePath;
50
51 @Override
52 public DefaultWeiXinBeanDefinition parse(WeiXinUserBean resources) {
53 String key = this.key;
54 Map<String, String> weixinInfoMap = null;
55 String appId = resources.getWxAppid();
56 String code = resources.getWxCode();
57 String userInfo = null;
58
59 if (StringUtils.isNotBlank(appId)) {
60
61 String decrypt = AESUtil.decrypt(appId, key);
62
63 if (decrypt != null) {
64 appId = decrypt.substring(16);
65 }
66
67 weixinInfoMap = getWeixinInfoByAppid(appId);
68 }
69
70 if (StringUtils.isNotBlank(code)) {
71 String decrypt = AESUtil.decrypt(code, key);
72 if (decrypt != null) {
73 code = decrypt.substring(16);
74 }
75 }
76
77 if (StringUtils.isNotBlank(userInfo)) {
78 String decrypt = AESUtil.decrypt(userInfo, key);
79 if (decrypt != null) {
80 userInfo = decrypt.substring(16);
81 }
82 }
83
84 return this.generateWeiXinBeanDefinition(code,userInfo,weixinInfoMap);
85 }
86
87 /**
88 *
89 * @param code
90 * @param userInfo
91 * @param weixinInfoMap
92 * @return
93 */
94 private DefaultWeiXinBeanDefinition generateWeiXinBeanDefinition(String code, String userInfo, Map<String, String> weixinInfoMap) {
95 String appId = weixinInfoMap.get("appid");
96 String secret = weixinInfoMap.get("secret");
97 JSONObject userInfoWxJo = null;
98
99 // 链接微信服务器
100 /*ResponseEntity<String> responseEntity1 = null;*//*restTemplate.exchange(WeChatConstants.CODE2SESSION.replace("APPID", appId)
101 .replace("SECRET", secret).replace("JSCODE", code),
102 HttpMethod.GET, null, String.class);*//*
103
104 String entityBody1 = responseEntity1.getBody();*/
105
106 String url = WeChatConstants.CODE2SESSION.replace("APPID", appId)
107 .replace("SECRET", secret).replace("JSCODE", code);
108 String entityBody = HttpUtil.get(url);
109
110 JSONObject jsonObject = JSONObject.parseObject(entityBody);
111
112 String openId = jsonObject.getString("openid");
113 String unionId = jsonObject.getString("unionid");
114
115 if (StringUtils.isEmpty(unionId)) {
116 try {
117 userInfoWxJo = this.weixinRequestUtil.getUserInfo(weixinInfoMap, openId,code);
118 } catch (Exception e) {
119 e.printStackTrace();
120 }
121 }
122
123 if (StringUtils.isNotBlank(userInfo)) {
124
125 JSONObject userInfoJo = JSONObject.parseObject(userInfo);
126 String encryptedData = userInfoJo.getString("encryptedData");
127 String iv = userInfoJo.getString("iv");
128 String key = jsonObject.getString("session_key");
129 String userInfoWeixin = AESUtil.decryptJsUserInfo(encryptedData, iv, key);
130 if (StringUtils.isNotEmpty(userInfoWeixin))
131 userInfoWxJo = JSONObject.parseObject(userInfoWeixin);
132 }
133
134 DefaultWeiXinBeanDefinition weiXinBeanDefinition =
135 new DefaultWeiXinBeanDefinition(appId,code,unionId,openId,userInfoWxJo,null);
136 return weiXinBeanDefinition;
137 }
138
139 /**
140 *
141 * @param appid
142 * @return
143 */
144 private Map<String, String> getWeixinInfoByAppid(String appid) {
145 if (StringUtils.isBlank(appid)) {
146 throw new RuntimeException("wxAppid can not be null");
147 }
148 List<Map<String, String>> list = this.weiXinAppListConfig.getList();
149 Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
150 if (!weixinInfoOptional.isPresent()) {
151 throw new RuntimeException("wxAppid error, appid is : " + appid);
152 }
153 return weixinInfoOptional.get();
154 }
155
156 }
...@@ -3,13 +3,10 @@ package com.topdraw.test.business.basicdata.member.rest; ...@@ -3,13 +3,10 @@ package com.topdraw.test.business.basicdata.member.rest;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.module.member.address.domain.MemberAddress; 4 import com.topdraw.business.module.member.address.domain.MemberAddress;
5 import com.topdraw.business.module.member.address.rest.MemberAddressController; 5 import com.topdraw.business.module.member.address.rest.MemberAddressController;
6 import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
7 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
8 import com.topdraw.BaseTest; 7 import com.topdraw.BaseTest;
9 import org.junit.Test; 8 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.data.domain.PageRequest;
12 import org.springframework.data.domain.Pageable;
13 10
14 public class MemberAddressControllerTest extends BaseTest { 11 public class MemberAddressControllerTest extends BaseTest {
15 12
......
...@@ -51,7 +51,7 @@ public class MemberControllerTest extends BaseTest { ...@@ -51,7 +51,7 @@ public class MemberControllerTest extends BaseTest {
51 member.setUserIptvId(1L); 51 member.setUserIptvId(1L);
52 member.setBindIptvPlatformType(0); 52 member.setBindIptvPlatformType(0);
53 String s = JSON.toJSONString(member); 53 String s = JSON.toJSONString(member);
54 ResultInfo byId = this.memberController.update(member); 54 ResultInfo byId = null;
55 LOG.info("===>>>"+byId); 55 LOG.info("===>>>"+byId);
56 } 56 }
57 57
...@@ -79,7 +79,7 @@ public class MemberControllerTest extends BaseTest { ...@@ -79,7 +79,7 @@ public class MemberControllerTest extends BaseTest {
79 member.setBindIptvPlatformType(0); 79 member.setBindIptvPlatformType(0);
80 member.setUpdateTime(LocalDateTime.now()); 80 member.setUpdateTime(LocalDateTime.now());
81 String s = JSON.toJSONString(member); 81 String s = JSON.toJSONString(member);
82 ResultInfo byId = this.memberController.create(member); 82 ResultInfo byId = null;//this.memberController.create(member);
83 LOG.info("===>>>"+byId); 83 LOG.info("===>>>"+byId);
84 } 84 }
85 85
......
...@@ -3,13 +3,10 @@ package com.topdraw.test.business.basicdata.member.rest; ...@@ -3,13 +3,10 @@ package com.topdraw.test.business.basicdata.member.rest;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo; 4 import com.topdraw.business.module.member.relatedinfo.domain.MemberRelatedInfo;
5 import com.topdraw.business.module.member.relatedinfo.rest.MemberRelatedInfoController; 5 import com.topdraw.business.module.member.relatedinfo.rest.MemberRelatedInfoController;
6 import com.topdraw.business.module.member.relatedinfo.service.dto.MemberRelatedInfoQueryCriteria;
7 import com.topdraw.common.ResultInfo; 6 import com.topdraw.common.ResultInfo;
8 import com.topdraw.BaseTest; 7 import com.topdraw.BaseTest;
9 import org.junit.Test; 8 import org.junit.Test;
10 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.data.domain.PageRequest;
12 import org.springframework.data.domain.Pageable;
13 10
14 import java.time.LocalDate; 11 import java.time.LocalDate;
15 12
......