Commit 2d8af089 2d8af0895aecb6ff03f3ca34a01cf4c2553b3ca9 by xianghan

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

1 parent 2413749b
package com.topdraw.business.module.contact.domain;
import com.topdraw.business.module.common.validated.CreateGroup;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-09-01
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_member_contacts")
public class MemberContacts implements Serializable {
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 会员id
@Column(name = "member_id", nullable = false)
@NotNull(groups = CreateGroup.class, message = "会员id不的为空")
private Long memberId;
// 用户id
@Column(name = "user_id")
private Long userId;
// 实体id
@Column(name = "entity_id")
private Long entityId;
// 实体类型 1:订单;2:商品;3:活动;99:其他
@Column(name = "entity_type")
private Long entityType;
// 实体code
@Column(name = "entity_code")
private String entityCode;
// 设备类型 1:大屏;2:微信;3:app;99:其他
@Column(name = "device_type")
@NotNull(groups = CreateGroup.class, message = "设备类型不的为空")
private Long deviceType;
// 姓名
@Column(name = "realname")
@NotNull(groups = CreateGroup.class, message = "姓名不的为空")
@NotEmpty(groups = CreateGroup.class, message = "姓名不的为空")
private String realname;
// 生日
@Column(name = "birthday")
private String birthday;
// 手机号
@Column(name = "phone")
@NotNull(groups = CreateGroup.class, message = "手机号不的为空")
private String phone;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(MemberContacts source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.contact.repository;
import com.topdraw.business.module.contact.domain.MemberContacts;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Optional;
/**
* @author XiangHan
* @date 2022-09-01
*/
public interface MemberContactsRepository extends JpaRepository<MemberContacts, Long>, JpaSpecificationExecutor<MemberContacts> {
}
package com.topdraw.business.module.contact.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.contact.service.MemberContactsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2022-09-01
*/
@Api(tags = "MemberContacts管理")
@RestController
@RequestMapping("/api/MemberContacts")
public class MemberContactsController {
@Autowired
private MemberContactsService MemberContactsService;
@PostMapping
@ApiOperation("新增MemberContacts")
public ResultInfo create(@Validated @RequestBody MemberContacts resources) {
MemberContactsService.create(resources);
return ResultInfo.success();
}
}
package com.topdraw.business.module.contact.service;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.contact.service.dto.MemberContactsDTO;
/**
* @author XiangHan
* @date 2022-09-01
*/
public interface MemberContactsService {
/**
* 根据ID查询
* @param id ID
* @return MemberContactsDTO
*/
MemberContactsDTO findById(Long id);
MemberContacts create(MemberContacts resources);
}
package com.topdraw.business.module.contact.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-09-01
*/
@Data
public class MemberContactsDTO implements Serializable {
// 主键
private Long id;
// 会员id
private Long memberId;
// 用户id
private Long userId;
// 实体id
private Long entityId;
// 实体类型 1:订单;2:商品;3:活动;99:其他
private Long entityType;
// 实体code
private String entityCode;
// 设备类型 1:大屏;2:微信;3:app;99:其他
private Long deviceType;
// 姓名
private String realname;
// 生日
private String birthday;
// 手机号
private String phone;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.contact.service.impl;
import com.topdraw.base.modules.utils.ValidationUtil;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.contact.repository.MemberContactsRepository;
import com.topdraw.business.module.contact.service.MemberContactsService;
import com.topdraw.business.module.contact.service.dto.MemberContactsDTO;
import com.topdraw.business.module.contact.service.mapper.MemberContactsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @author XiangHan
* @date 2022-09-01
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MemberContactsServiceImpl implements MemberContactsService {
@Autowired
private MemberContactsRepository MemberContactsRepository;
@Autowired
private MemberContactsMapper MemberContactsMapper;
@Override
public MemberContactsDTO findById(Long id) {
MemberContacts MemberContacts = MemberContactsRepository.findById(id).orElseGet(MemberContacts::new);
ValidationUtil.isNull(MemberContacts.getId(),"MemberContacts","id",id);
return MemberContactsMapper.toDto(MemberContacts);
}
@Override
@Transactional(rollbackFor = Exception.class)
public MemberContacts create(MemberContacts resources) {
return MemberContactsRepository.save(resources);
}
}
package com.topdraw.business.module.contact.service.mapper;
import com.topdraw.base.modules.base.BaseMapper;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.contact.service.dto.MemberContactsDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-09-01
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MemberContactsMapper extends BaseMapper<MemberContactsDTO, MemberContacts> {
}
......@@ -3,13 +3,17 @@ package com.topdraw.business.process.rest;
import com.topdraw.base.modules.annotation.AnonymousAccess;
import com.topdraw.base.modules.common.IResultInfo;
import com.topdraw.base.modules.common.ResultInfo;
import com.topdraw.business.module.common.validated.CreateGroup;
import com.topdraw.business.module.common.validated.UpdateGroup;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.contact.service.MemberContactsService;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.process.domian.member.MemberOperationBean;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.util.RegexUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -87,6 +91,19 @@ public class MemberOperationController {
MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId);
return ResultInfo.success(memberProfileDTO);
}
@PostMapping("/createMemberContacts")
@ApiOperation("新增会员联络信息")
@AnonymousAccess
public ResultInfo createMemberContacts(@Validated(value = {CreateGroup.class}) @RequestBody MemberContacts resources) {
log.info("新增会员联络信息,参数 createMemberContacts# ==>> {}", resources);
if (!RegexUtil.mobileRegex(resources.getPhone())) {
return ResultInfo.failure("手机号格式不正确,请确认");
}
return this.memberOperationService.createMemberContacts(resources);
}
}
......
......@@ -2,6 +2,9 @@ package com.topdraw.business.process.service.impl.member;
import cn.hutool.core.util.ObjectUtil;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.base.modules.common.ResultInfo;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.contact.service.MemberContactsService;
import com.topdraw.business.module.member.address.service.MemberAddressService;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.domain.Member;
......@@ -25,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;
......@@ -44,10 +48,13 @@ public class MemberOperationServiceImpl implements MemberOperationService {
@Autowired
private MemberAddressService memberAddressService;
@Autowired
private MemberContactsService memberContactsService;
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@Override
public MemberDTO findByCode(String code) {
return this.memberService.findByCode(code);
......@@ -157,6 +164,11 @@ public class MemberOperationServiceImpl implements MemberOperationService {
return null;
}
@Override
public ResultInfo createMemberContacts(MemberContacts resources) {
return ResultInfo.success(this.memberContactsService.create(resources));
}
@Override
public MemberProfileDTO getMemberProfileAndCheckVip(Long memberId, String appId) {
......
package com.topdraw.business.process.service.member;
import com.topdraw.base.modules.common.ResultInfo;
import com.topdraw.business.module.contact.domain.MemberContacts;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
......@@ -87,4 +89,11 @@ public interface MemberOperationService {
* @return
*/
MemberAddressDTO updateDefaultMemberAddressById(Long memberId);
/**
*
* @param resources
* @return
*/
ResultInfo createMemberContacts(MemberContacts resources);
}
......
......@@ -39,14 +39,14 @@ public class GeneratorCode extends BaseTest {
@Rollback(value = false)
@Transactional(rollbackFor = Exception.class)
public void generator() {
var dbName = "uc_growth_report";
var dbName = "uc_member_contacts";
// 表名称,支持多表
var tableNames = Arrays.asList(dbName);
String[] s = dbName.split("_");
var pre = s[0];
var target1 = s[s.length-1];
var preRoute = "com.topdraw.business.module.user.iptv.growreport";
var preRoute = "com.topdraw.business.module.contact";
StringBuilder builder = new StringBuilder(preRoute);
// builder.append("wechatshare");
// builder.append(target);
......