Commit 2d8af089 2d8af0895aecb6ff03f3ca34a01cf4c2553b3ca9 by xianghan

1.修复微信应用登录时,昵称重复base64加密的问题

1 parent 2413749b
1 package com.topdraw.business.module.contact.domain;
2
3 import com.topdraw.business.module.common.validated.CreateGroup;
4 import lombok.Data;
5 import lombok.experimental.Accessors;
6 import cn.hutool.core.bean.BeanUtil;
7 import cn.hutool.core.bean.copier.CopyOptions;
8 import javax.persistence.*;
9 import javax.validation.constraints.NotEmpty;
10 import javax.validation.constraints.NotNull;
11
12 import org.springframework.data.annotation.CreatedDate;
13 import org.springframework.data.annotation.LastModifiedDate;
14 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
15 import java.sql.Timestamp;
16
17 import java.io.Serializable;
18
19 /**
20 * @author XiangHan
21 * @date 2022-09-01
22 */
23 @Entity
24 @Data
25 @EntityListeners(AuditingEntityListener.class)
26 @Accessors(chain = true)
27 @Table(name="uc_member_contacts")
28 public class MemberContacts implements Serializable {
29
30 // 主键
31 @Id
32 @GeneratedValue(strategy = GenerationType.IDENTITY)
33 @Column(name = "id")
34 private Long id;
35
36 // 会员id
37 @Column(name = "member_id", nullable = false)
38 @NotNull(groups = CreateGroup.class, message = "会员id不的为空")
39 private Long memberId;
40
41 // 用户id
42 @Column(name = "user_id")
43 private Long userId;
44
45 // 实体id
46 @Column(name = "entity_id")
47 private Long entityId;
48
49 // 实体类型 1:订单;2:商品;3:活动;99:其他
50 @Column(name = "entity_type")
51 private Long entityType;
52
53 // 实体code
54 @Column(name = "entity_code")
55 private String entityCode;
56
57 // 设备类型 1:大屏;2:微信;3:app;99:其他
58 @Column(name = "device_type")
59 @NotNull(groups = CreateGroup.class, message = "设备类型不的为空")
60 private Long deviceType;
61
62 // 姓名
63 @Column(name = "realname")
64 @NotNull(groups = CreateGroup.class, message = "姓名不的为空")
65 @NotEmpty(groups = CreateGroup.class, message = "姓名不的为空")
66 private String realname;
67
68 // 生日
69 @Column(name = "birthday")
70 private String birthday;
71
72 // 手机号
73 @Column(name = "phone")
74 @NotNull(groups = CreateGroup.class, message = "手机号不的为空")
75 private String phone;
76
77 // 创建时间
78 @CreatedDate
79 @Column(name = "create_time")
80 private Timestamp createTime;
81
82 // 更新时间
83 @LastModifiedDate
84 @Column(name = "update_time")
85 private Timestamp updateTime;
86
87 public void copy(MemberContacts source){
88 BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
89 }
90 }
1 package com.topdraw.business.module.contact.repository;
2
3 import com.topdraw.business.module.contact.domain.MemberContacts;
4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6
7 import java.util.Optional;
8
9 /**
10 * @author XiangHan
11 * @date 2022-09-01
12 */
13 public interface MemberContactsRepository extends JpaRepository<MemberContacts, Long>, JpaSpecificationExecutor<MemberContacts> {
14
15 }
1 package com.topdraw.business.module.contact.rest;
2
3 import com.topdraw.common.ResultInfo;
4 import com.topdraw.business.module.contact.domain.MemberContacts;
5 import com.topdraw.business.module.contact.service.MemberContactsService;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.validation.annotation.Validated;
8 import org.springframework.web.bind.annotation.*;
9 import io.swagger.annotations.*;
10
11 /**
12 * @author XiangHan
13 * @date 2022-09-01
14 */
15 @Api(tags = "MemberContacts管理")
16 @RestController
17 @RequestMapping("/api/MemberContacts")
18 public class MemberContactsController {
19
20 @Autowired
21 private MemberContactsService MemberContactsService;
22
23 @PostMapping
24 @ApiOperation("新增MemberContacts")
25 public ResultInfo create(@Validated @RequestBody MemberContacts resources) {
26 MemberContactsService.create(resources);
27 return ResultInfo.success();
28 }
29
30 }
1 package com.topdraw.business.module.contact.service;
2
3 import com.topdraw.business.module.contact.domain.MemberContacts;
4 import com.topdraw.business.module.contact.service.dto.MemberContactsDTO;
5
6 /**
7 * @author XiangHan
8 * @date 2022-09-01
9 */
10 public interface MemberContactsService {
11
12 /**
13 * 根据ID查询
14 * @param id ID
15 * @return MemberContactsDTO
16 */
17 MemberContactsDTO findById(Long id);
18
19 MemberContacts create(MemberContacts resources);
20
21 }
1 package com.topdraw.business.module.contact.service.dto;
2
3 import lombok.Data;
4 import java.sql.Timestamp;
5 import java.io.Serializable;
6
7
8 /**
9 * @author XiangHan
10 * @date 2022-09-01
11 */
12 @Data
13 public class MemberContactsDTO implements Serializable {
14
15 // 主键
16 private Long id;
17
18 // 会员id
19 private Long memberId;
20
21 // 用户id
22 private Long userId;
23
24 // 实体id
25 private Long entityId;
26
27 // 实体类型 1:订单;2:商品;3:活动;99:其他
28 private Long entityType;
29
30 // 实体code
31 private String entityCode;
32
33 // 设备类型 1:大屏;2:微信;3:app;99:其他
34 private Long deviceType;
35
36 // 姓名
37 private String realname;
38
39 // 生日
40 private String birthday;
41
42 // 手机号
43 private String phone;
44
45 // 创建时间
46 private Timestamp createTime;
47
48 // 更新时间
49 private Timestamp updateTime;
50 }
1 package com.topdraw.business.module.contact.service.impl;
2
3 import com.topdraw.base.modules.utils.ValidationUtil;
4 import com.topdraw.business.module.contact.domain.MemberContacts;
5 import com.topdraw.business.module.contact.repository.MemberContactsRepository;
6 import com.topdraw.business.module.contact.service.MemberContactsService;
7 import com.topdraw.business.module.contact.service.dto.MemberContactsDTO;
8 import com.topdraw.business.module.contact.service.mapper.MemberContactsMapper;
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 XiangHan
16 * @date 2022-09-01
17 */
18 @Service
19 @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
20 public class MemberContactsServiceImpl implements MemberContactsService {
21
22 @Autowired
23 private MemberContactsRepository MemberContactsRepository;
24
25 @Autowired
26 private MemberContactsMapper MemberContactsMapper;
27
28 @Override
29 public MemberContactsDTO findById(Long id) {
30 MemberContacts MemberContacts = MemberContactsRepository.findById(id).orElseGet(MemberContacts::new);
31 ValidationUtil.isNull(MemberContacts.getId(),"MemberContacts","id",id);
32 return MemberContactsMapper.toDto(MemberContacts);
33 }
34
35 @Override
36 @Transactional(rollbackFor = Exception.class)
37 public MemberContacts create(MemberContacts resources) {
38 return MemberContactsRepository.save(resources);
39 }
40
41 }
1 package com.topdraw.business.module.contact.service.mapper;
2
3 import com.topdraw.base.modules.base.BaseMapper;
4 import com.topdraw.business.module.contact.domain.MemberContacts;
5 import com.topdraw.business.module.contact.service.dto.MemberContactsDTO;
6 import org.mapstruct.Mapper;
7 import org.mapstruct.ReportingPolicy;
8
9 /**
10 * @author XiangHan
11 * @date 2022-09-01
12 */
13 @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
14 public interface MemberContactsMapper extends BaseMapper<MemberContactsDTO, MemberContacts> {
15
16 }
...@@ -3,13 +3,17 @@ package com.topdraw.business.process.rest; ...@@ -3,13 +3,17 @@ package com.topdraw.business.process.rest;
3 import com.topdraw.base.modules.annotation.AnonymousAccess; 3 import com.topdraw.base.modules.annotation.AnonymousAccess;
4 import com.topdraw.base.modules.common.IResultInfo; 4 import com.topdraw.base.modules.common.IResultInfo;
5 import com.topdraw.base.modules.common.ResultInfo; 5 import com.topdraw.base.modules.common.ResultInfo;
6 import com.topdraw.business.module.common.validated.CreateGroup;
6 import com.topdraw.business.module.common.validated.UpdateGroup; 7 import com.topdraw.business.module.common.validated.UpdateGroup;
8 import com.topdraw.business.module.contact.domain.MemberContacts;
9 import com.topdraw.business.module.contact.service.MemberContactsService;
7 import com.topdraw.business.module.member.address.domain.MemberAddress; 10 import com.topdraw.business.module.member.address.domain.MemberAddress;
8 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; 11 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
9 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; 12 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
10 import com.topdraw.business.module.member.service.dto.MemberDTO; 13 import com.topdraw.business.module.member.service.dto.MemberDTO;
11 import com.topdraw.business.process.domian.member.MemberOperationBean; 14 import com.topdraw.business.process.domian.member.MemberOperationBean;
12 import com.topdraw.business.process.service.member.MemberOperationService; 15 import com.topdraw.business.process.service.member.MemberOperationService;
16 import com.topdraw.util.RegexUtil;
13 import io.swagger.annotations.Api; 17 import io.swagger.annotations.Api;
14 import io.swagger.annotations.ApiOperation; 18 import io.swagger.annotations.ApiOperation;
15 import lombok.extern.slf4j.Slf4j; 19 import lombok.extern.slf4j.Slf4j;
...@@ -87,6 +91,19 @@ public class MemberOperationController { ...@@ -87,6 +91,19 @@ public class MemberOperationController {
87 MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId); 91 MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId);
88 return ResultInfo.success(memberProfileDTO); 92 return ResultInfo.success(memberProfileDTO);
89 } 93 }
94
95 @PostMapping("/createMemberContacts")
96 @ApiOperation("新增会员联络信息")
97 @AnonymousAccess
98 public ResultInfo createMemberContacts(@Validated(value = {CreateGroup.class}) @RequestBody MemberContacts resources) {
99 log.info("新增会员联络信息,参数 createMemberContacts# ==>> {}", resources);
100
101 if (!RegexUtil.mobileRegex(resources.getPhone())) {
102 return ResultInfo.failure("手机号格式不正确,请确认");
103 }
104
105 return this.memberOperationService.createMemberContacts(resources);
106 }
90 } 107 }
91 108
92 109
......
...@@ -2,6 +2,9 @@ package com.topdraw.business.process.service.impl.member; ...@@ -2,6 +2,9 @@ package com.topdraw.business.process.service.impl.member;
2 2
3 import cn.hutool.core.util.ObjectUtil; 3 import cn.hutool.core.util.ObjectUtil;
4 import com.topdraw.aspect.AsyncMqSend; 4 import com.topdraw.aspect.AsyncMqSend;
5 import com.topdraw.base.modules.common.ResultInfo;
6 import com.topdraw.business.module.contact.domain.MemberContacts;
7 import com.topdraw.business.module.contact.service.MemberContactsService;
5 import com.topdraw.business.module.member.address.service.MemberAddressService; 8 import com.topdraw.business.module.member.address.service.MemberAddressService;
6 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; 9 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
7 import com.topdraw.business.module.member.domain.Member; 10 import com.topdraw.business.module.member.domain.Member;
...@@ -25,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -25,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.cache.annotation.CacheConfig; 28 import org.springframework.cache.annotation.CacheConfig;
26 import org.springframework.stereotype.Service; 29 import org.springframework.stereotype.Service;
27 30
31 import javax.validation.constraints.NotNull;
28 import java.sql.Timestamp; 32 import java.sql.Timestamp;
29 import java.util.List; 33 import java.util.List;
30 import java.util.Objects; 34 import java.util.Objects;
...@@ -44,10 +48,13 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -44,10 +48,13 @@ public class MemberOperationServiceImpl implements MemberOperationService {
44 @Autowired 48 @Autowired
45 private MemberAddressService memberAddressService; 49 private MemberAddressService memberAddressService;
46 @Autowired 50 @Autowired
51 private MemberContactsService memberContactsService;
52 @Autowired
47 private MemberVipHistoryService memberVipHistoryService; 53 private MemberVipHistoryService memberVipHistoryService;
48 54
49 55
50 56
57
51 @Override 58 @Override
52 public MemberDTO findByCode(String code) { 59 public MemberDTO findByCode(String code) {
53 return this.memberService.findByCode(code); 60 return this.memberService.findByCode(code);
...@@ -157,6 +164,11 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -157,6 +164,11 @@ public class MemberOperationServiceImpl implements MemberOperationService {
157 return null; 164 return null;
158 } 165 }
159 166
167 @Override
168 public ResultInfo createMemberContacts(MemberContacts resources) {
169 return ResultInfo.success(this.memberContactsService.create(resources));
170 }
171
160 172
161 @Override 173 @Override
162 public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appId) { 174 public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appId) {
......
1 package com.topdraw.business.process.service.member; 1 package com.topdraw.business.process.service.member;
2 2
3 import com.topdraw.base.modules.common.ResultInfo;
4 import com.topdraw.business.module.contact.domain.MemberContacts;
3 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO; 5 import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
4 import com.topdraw.business.module.member.domain.Member; 6 import com.topdraw.business.module.member.domain.Member;
5 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; 7 import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
...@@ -87,4 +89,11 @@ public interface MemberOperationService { ...@@ -87,4 +89,11 @@ public interface MemberOperationService {
87 * @return 89 * @return
88 */ 90 */
89 MemberAddressDTO updateDefaultMemberAddressById(Long memberId); 91 MemberAddressDTO updateDefaultMemberAddressById(Long memberId);
92
93 /**
94 *
95 * @param resources
96 * @return
97 */
98 ResultInfo createMemberContacts(MemberContacts resources);
90 } 99 }
......
...@@ -39,14 +39,14 @@ public class GeneratorCode extends BaseTest { ...@@ -39,14 +39,14 @@ public class GeneratorCode extends BaseTest {
39 @Rollback(value = false) 39 @Rollback(value = false)
40 @Transactional(rollbackFor = Exception.class) 40 @Transactional(rollbackFor = Exception.class)
41 public void generator() { 41 public void generator() {
42 var dbName = "uc_growth_report"; 42 var dbName = "uc_member_contacts";
43 // 表名称,支持多表 43 // 表名称,支持多表
44 var tableNames = Arrays.asList(dbName); 44 var tableNames = Arrays.asList(dbName);
45 String[] s = dbName.split("_"); 45 String[] s = dbName.split("_");
46 46
47 var pre = s[0]; 47 var pre = s[0];
48 var target1 = s[s.length-1]; 48 var target1 = s[s.length-1];
49 var preRoute = "com.topdraw.business.module.user.iptv.growreport"; 49 var preRoute = "com.topdraw.business.module.contact";
50 StringBuilder builder = new StringBuilder(preRoute); 50 StringBuilder builder = new StringBuilder(preRoute);
51 // builder.append("wechatshare"); 51 // builder.append("wechatshare");
52 // builder.append(target); 52 // builder.append(target);
......