Commit 2e2bd9da authored by xiaoguang.xu's avatar xiaoguang.xu

Merge branch 'baseEntity' into contactIsolate

# Conflicts:
#	src/main/java/cn/quantgroup/xyqb/entity/Contact.java
#	src/main/java/cn/quantgroup/xyqb/service/user/impl/ContactServiceImpl.java
parents 94e07368 f2b7aadb
package cn.quantgroup.xyqb.config.mq; package cn.quantgroup.xyqb.config.mq;
import cn.quantgroup.tech.brave.service.ITechRabbitBuilder; import cn.quantgroup.tech.brave.service.ITechRabbitBuilder;
import org.springframework.amqp.core.*; import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode;
import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/** /**
* Created by xuran on 2017/9/7. * Created by xuran on 2017/9/7.
...@@ -113,4 +121,35 @@ public class RegisterMqConfig { ...@@ -113,4 +121,35 @@ public class RegisterMqConfig {
template.setExchange(exchange4Gdt); template.setExchange(exchange4Gdt);
return template; return template;
} }
@Bean(name = "commonConnectionFactory")
public ConnectionFactory commonConnectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, port);
connectionFactory.setCacheMode(CacheMode.CHANNEL);
//根据使用情况动态调整。
connectionFactory.setChannelCacheSize(100);
connectionFactory.setUsername(user);
connectionFactory.setPassword(password);
connectionFactory.setVirtualHost("/");
connectionFactory.setPublisherReturns(false);
connectionFactory.setPublisherConfirms(false);
return connectionFactory;
}
@Bean(name = "wechatRabbitTemplate")
public RabbitTemplate wechatRabbitTemplate(@Qualifier("commonConnectionFactory") ConnectionFactory commonConnectionFactory) {
RabbitTemplate rabbitTemplate = techRabbitBuilder.createRabbitTemplate(commonConnectionFactory);
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
RabbitAdmin rabbitAdmin = new RabbitAdmin(commonConnectionFactory);
String queueName = "wechat_bind";
Map<String, Object> queueArgs = new HashMap<>();
//数据 1 天有效期
queueArgs.put("x-message-ttl", 24 * 60 * 60 * 1000);
Queue wechatBind = new Queue(queueName, true, false, false, queueArgs);
rabbitAdmin.declareQueue(wechatBind);
// rabbitTemplate.setQueue(queueName);
rabbitTemplate.setRoutingKey(queueName);
return rabbitTemplate;
}
} }
...@@ -64,17 +64,14 @@ public class UserDetailController implements IBaseController { ...@@ -64,17 +64,14 @@ public class UserDetailController implements IBaseController {
log.error("身份证号错误,userId:{}, idNo: {}", user.getId(), idNo); log.error("身份证号错误,userId:{}, idNo: {}", user.getId(), idNo);
return JsonResult.buildErrorStateResult("身份证号码错误", null); return JsonResult.buildErrorStateResult("身份证号码错误", null);
} }
Timestamp now = new Timestamp(System.currentTimeMillis());
/* 保存或更新 */ /* 保存或更新 */
UserDetail userDetail = userDetailService.findByUserId(user.getId()); UserDetail userDetail = userDetailService.findByUserId(user.getId());
if (Objects.isNull(userDetail)) { if (Objects.isNull(userDetail)) {
userDetail = new UserDetail(); userDetail = new UserDetail();
userDetail.setCreatedAt(now);
} }
userDetail.setIdNo(idNo); userDetail.setIdNo(idNo);
userDetail.setPhoneNo(user.getPhoneNo()); userDetail.setPhoneNo(user.getPhoneNo());
userDetail.setUserId(user.getId()); userDetail.setUserId(user.getId());
userDetail.setUpdatedAt(now);
userDetail.setName(name); userDetail.setName(name);
userDetail.setGender(info.getGender()); userDetail.setGender(info.getGender());
userDetail.setIdType(IdType.ID_CARD); userDetail.setIdType(IdType.ID_CARD);
......
...@@ -328,7 +328,6 @@ public class InnerController implements IBaseController { ...@@ -328,7 +328,6 @@ public class InnerController implements IBaseController {
} else if (!Objects.equals(user.getPhoneNo(), phoneNo)) { } else if (!Objects.equals(user.getPhoneNo(), phoneNo)) {
return JsonResult.buildErrorStateResult("用户手机号不匹配", null); return JsonResult.buildErrorStateResult("用户手机号不匹配", null);
} }
Timestamp now = new Timestamp(System.currentTimeMillis());
/* /*
* 如果已存在记录,则更新 * 如果已存在记录,则更新
*/ */
...@@ -342,13 +341,11 @@ public class InnerController implements IBaseController { ...@@ -342,13 +341,11 @@ public class InnerController implements IBaseController {
} }
if (Objects.isNull(userDetail)) { if (Objects.isNull(userDetail)) {
userDetail = new UserDetail(); userDetail = new UserDetail();
userDetail.setCreatedAt(now);
} }
userDetail.setUserId(userId); userDetail.setUserId(userId);
userDetail.setName(name); userDetail.setName(name);
userDetail.setPhoneNo(phoneNo); userDetail.setPhoneNo(phoneNo);
userDetail.setIdNo(idNo); userDetail.setIdNo(idNo);
userDetail.setUpdatedAt(now);
userDetail.setIdType(IdType.ID_CARD); userDetail.setIdType(IdType.ID_CARD);
userDetail.setGender(info.getGender()); userDetail.setGender(info.getGender());
userDetail.setEmail(email); userDetail.setEmail(email);
...@@ -568,9 +565,6 @@ public class InnerController implements IBaseController { ...@@ -568,9 +565,6 @@ public class InnerController implements IBaseController {
Address addressObj = addressService.findByUserId(userId); Address addressObj = addressService.findByUserId(userId);
if (addressObj == null) { if (addressObj == null) {
addressObj = new Address(); addressObj = new Address();
Timestamp now = new Timestamp(System.currentTimeMillis());
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
} }
addressObj.setUserId(userId); addressObj.setUserId(userId);
addressObj.setProvince(province); addressObj.setProvince(province);
...@@ -595,13 +589,10 @@ public class InnerController implements IBaseController { ...@@ -595,13 +589,10 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("用户ID不能为空", null); return JsonResult.buildErrorStateResult("用户ID不能为空", null);
} }
UserExtInfo info = userExtInfoService.findByUserId(userId); UserExtInfo info = userExtInfoService.findByUserId(userId);
Timestamp now = new Timestamp(System.currentTimeMillis());
if (info == null) { if (info == null) {
info = new UserExtInfo(); info = new UserExtInfo();
info.setUserId(userId); info.setUserId(userId);
info.setCreatedAt(now);
} }
info.setUpdateAt(now);
if (incomeEnum != null) { if (incomeEnum != null) {
info.setIncomeEnum(cn.quantgroup.user.enums.IncomeEnum.valueOf(incomeEnum.name())); info.setIncomeEnum(cn.quantgroup.user.enums.IncomeEnum.valueOf(incomeEnum.name()));
} }
...@@ -976,7 +967,6 @@ public class InnerController implements IBaseController { ...@@ -976,7 +967,6 @@ public class InnerController implements IBaseController {
return false; return false;
} }
user.setEnable(enable); user.setEnable(enable);
user.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
log.info("刷新用户激活状态失败:userId:{},enable:{},user:{}", userId, enable, user); log.info("刷新用户激活状态失败:userId:{},enable:{},user:{}", userId, enable, user);
user = userService.saveUser(user); user = userService.saveUser(user);
if (!user.getEnable()) { if (!user.getEnable()) {
...@@ -1003,15 +993,12 @@ public class InnerController implements IBaseController { ...@@ -1003,15 +993,12 @@ public class InnerController implements IBaseController {
} }
} }
UserSpouse userSpouse = userSpouseService.findByUserId(userId); UserSpouse userSpouse = userSpouseService.findByUserId(userId);
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
if (userSpouse == null) { if (userSpouse == null) {
userSpouse = new UserSpouse(userId); userSpouse = new UserSpouse(userId);
userSpouse.setCreatedAt(timestamp);
} }
userSpouse.setSpouseName(status == MaritalStatus.MARRIED ? spouseName : ""); userSpouse.setSpouseName(status == MaritalStatus.MARRIED ? spouseName : "");
userSpouse.setSpousePhone(status == MaritalStatus.MARRIED ? spousePhone : ""); userSpouse.setSpousePhone(status == MaritalStatus.MARRIED ? spousePhone : "");
userSpouse.setStatus(cn.quantgroup.user.enums.MaritalStatus.valueOf(status.name())); userSpouse.setStatus(cn.quantgroup.user.enums.MaritalStatus.valueOf(status.name()));
userSpouse.setUpdateAt(timestamp);
userSpouse = userSpouseService.save(userSpouse); userSpouse = userSpouseService.save(userSpouse);
return JsonResult.buildSuccessResult(null, UserSpouseRet.getUserSpouseRet(userSpouse)); return JsonResult.buildSuccessResult(null, UserSpouseRet.getUserSpouseRet(userSpouse));
} }
......
...@@ -71,17 +71,14 @@ public class SyncUserController { ...@@ -71,17 +71,14 @@ public class SyncUserController {
log.error("用户不存在,phoneNo:{}", phoneNo); log.error("用户不存在,phoneNo:{}", phoneNo);
return JsonResult.buildErrorStateResult("用户不存在", phoneNo); return JsonResult.buildErrorStateResult("用户不存在", phoneNo);
} }
Timestamp now = new Timestamp(System.currentTimeMillis());
/* 保存或更新 */ /* 保存或更新 */
UserDetail userDetail = userDetailService.findByUserId(user.getId()); UserDetail userDetail = userDetailService.findByUserId(user.getId());
if (Objects.isNull(userDetail)) { if (Objects.isNull(userDetail)) {
userDetail = new UserDetail(); userDetail = new UserDetail();
userDetail.setCreatedAt(now);
} }
userDetail.setUserId(user.getId()); userDetail.setUserId(user.getId());
userDetail.setIdNo(idNo); userDetail.setIdNo(idNo);
userDetail.setPhoneNo(phoneNo); userDetail.setPhoneNo(phoneNo);
userDetail.setUpdatedAt(now);
userDetail.setName(name); userDetail.setName(name);
userDetail.setGender(info.getGender()); userDetail.setGender(info.getGender());
userDetail.setIdType(IdType.ID_CARD); userDetail.setIdType(IdType.ID_CARD);
......
...@@ -291,10 +291,8 @@ public class UserCenterController { ...@@ -291,10 +291,8 @@ public class UserCenterController {
} }
//查询用户是否有保存地址信息 //查询用户是否有保存地址信息
Address addressInfo = addressService.findByUserId(userId); Address addressInfo = addressService.findByUserId(userId);
Timestamp now = new Timestamp(System.currentTimeMillis());
if (null == addressInfo) { if (null == addressInfo) {
addressInfo = new Address(); addressInfo = new Address();
addressInfo.setCreatedAt(now);
} }
addressInfo.setUserId(userId); addressInfo.setUserId(userId);
addressInfo.setProvince(province); addressInfo.setProvince(province);
...@@ -304,7 +302,6 @@ public class UserCenterController { ...@@ -304,7 +302,6 @@ public class UserCenterController {
addressInfo.setDistrictCode(districtCode); addressInfo.setDistrictCode(districtCode);
addressInfo.setDistrict(district); addressInfo.setDistrict(district);
addressInfo.setAddress(address); addressInfo.setAddress(address);
addressInfo.setUpdateAt(now);
addressService.save(addressInfo); addressService.save(addressInfo);
return JsonResult.buildSuccessResult(null, addressInfo); return JsonResult.buildSuccessResult(null, addressInfo);
} }
...@@ -374,13 +371,10 @@ public class UserCenterController { ...@@ -374,13 +371,10 @@ public class UserCenterController {
} }
//查询用户是否保存过. //查询用户是否保存过.
UserExtInfo userExtInfo = userExtInfoService.findByUserId(userId); UserExtInfo userExtInfo = userExtInfoService.findByUserId(userId);
Timestamp now = new Timestamp(System.currentTimeMillis());
if (null == userExtInfo) { if (null == userExtInfo) {
userExtInfo = new UserExtInfo(); userExtInfo = new UserExtInfo();
userExtInfo.setUserId(userId); userExtInfo.setUserId(userId);
} }
userExtInfo.setCreatedAt(now);
userExtInfo.setUpdateAt(now);
userExtInfo.setEducationEnum(educationEnum); userExtInfo.setEducationEnum(educationEnum);
userExtInfo.setMarryStatus(maritalStatus); userExtInfo.setMarryStatus(maritalStatus);
userExtInfo.setOccupationEnum(occupationEnum); userExtInfo.setOccupationEnum(occupationEnum);
......
...@@ -48,7 +48,6 @@ public class UserDetailController { ...@@ -48,7 +48,6 @@ public class UserDetailController {
//更新 //更新
userDetail.setName(userDetailReq.getName()); userDetail.setName(userDetailReq.getName());
userDetail.setIdNo(userDetailReq.getIdNo()); userDetail.setIdNo(userDetailReq.getIdNo());
userDetail.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
userDetail = userDetailService.saveUserDetail(userDetail); userDetail = userDetailService.saveUserDetail(userDetail);
return JsonResult.buildSuccessResultGeneric(userDetail); return JsonResult.buildSuccessResultGeneric(userDetail);
} }
...@@ -69,7 +68,6 @@ public class UserDetailController { ...@@ -69,7 +68,6 @@ public class UserDetailController {
} }
User user = userService.findById(userId); User user = userService.findById(userId);
IdCardInfo idCardInfo = idCardService.getIdCardInfo(userDetailReq.getIdNo()); IdCardInfo idCardInfo = idCardService.getIdCardInfo(userDetailReq.getIdNo());
Timestamp now = new Timestamp(System.currentTimeMillis());
userDetail = new UserDetail(); userDetail = new UserDetail();
userDetail.setUserId(userId); userDetail.setUserId(userId);
...@@ -78,8 +76,6 @@ public class UserDetailController { ...@@ -78,8 +76,6 @@ public class UserDetailController {
userDetail.setIdNo(userDetailReq.getIdNo()); userDetail.setIdNo(userDetailReq.getIdNo());
userDetail.setIdType(IdType.ID_CARD); userDetail.setIdType(IdType.ID_CARD);
userDetail.setGender(idCardInfo.getGender()); userDetail.setGender(idCardInfo.getGender());
userDetail.setCreatedAt(now);
userDetail.setUpdatedAt(now);
userDetail = userDetailService.saveUserDetail(userDetail); userDetail = userDetailService.saveUserDetail(userDetail);
return JsonResult.buildSuccessResultGeneric(userDetail); return JsonResult.buildSuccessResultGeneric(userDetail);
} }
......
...@@ -10,13 +10,24 @@ import cn.quantgroup.xyqb.entity.ModifyPhoneNo; ...@@ -10,13 +10,24 @@ import cn.quantgroup.xyqb.entity.ModifyPhoneNo;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.user.IModifyPhoneNoService; import cn.quantgroup.xyqb.service.user.IModifyPhoneNoService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationConfig;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/** /**
* 用户手机号修改相关api * 用户手机号修改相关api
...@@ -81,8 +92,18 @@ public class ModifyPhoneNoController implements IBaseController { ...@@ -81,8 +92,18 @@ public class ModifyPhoneNoController implements IBaseController {
*/ */
@ApiOperation("后台客服处理功能 - 查询列表") @ApiOperation("后台客服处理功能 - 查询列表")
@GetMapping @GetMapping
public JsonResult<Page<ModifyPhoneNo>> list(@Valid ModifyPhoneNoQueryReq modifyPhoneNoQueryReq) { public JsonResult<?> list(@Valid ModifyPhoneNoQueryReq modifyPhoneNoQueryReq) {
return JsonResult.buildSuccessResultGeneric(modifyPhoneNoService.list(modifyPhoneNoQueryReq)); Page<ModifyPhoneNo> list = modifyPhoneNoService.list(modifyPhoneNoQueryReq);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
String s;
try {
s = objectMapper.writeValueAsString(list);
Object o = objectMapper.readValue(s, Object.class);
return JsonResult.buildSuccessResultGeneric(o);
} catch (Exception ignored) {
}
return JsonResult.buildErrorStateResult("数据错误",null);
} }
/** /**
......
...@@ -65,9 +65,6 @@ public class Step1Req implements Serializable { ...@@ -65,9 +65,6 @@ public class Step1Req implements Serializable {
public static ModifyPhoneNo adapt(Step1Req step1Req) { public static ModifyPhoneNo adapt(Step1Req step1Req) {
ModifyPhoneNo modifyPhoneNo = new ModifyPhoneNo(); ModifyPhoneNo modifyPhoneNo = new ModifyPhoneNo();
BeanUtils.copyProperties(step1Req, modifyPhoneNo); BeanUtils.copyProperties(step1Req, modifyPhoneNo);
Date date = new Date();
modifyPhoneNo.setCreatedAt(date);
modifyPhoneNo.setUpdatedAt(date);
return modifyPhoneNo ; return modifyPhoneNo ;
} }
} }
...@@ -13,14 +13,10 @@ import java.sql.Timestamp; ...@@ -13,14 +13,10 @@ import java.sql.Timestamp;
@Data @Data
@Entity @Entity
@Table(name = "address", uniqueConstraints = @UniqueConstraint(columnNames = "user_id")) @Table(name = "address", uniqueConstraints = @UniqueConstraint(columnNames = "user_id"))
public class Address implements Serializable { public class Address extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
@Column(name = "province_code") @Column(name = "province_code")
...@@ -37,15 +33,7 @@ public class Address implements Serializable { ...@@ -37,15 +33,7 @@ public class Address implements Serializable {
private String district; private String district;
@Column(name = "address") @Column(name = "address")
private String address; private String address;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updateAt;
@PreUpdate
public void preUpdate() {
this.updateAt = new Timestamp(System.currentTimeMillis());
}
public String toString() { public String toString() {
return province + "(省)" + city + "(市)" + district + "(区/县)" + address; return province + "(省)" + city + "(市)" + district + "(区/县)" + address;
......
package cn.quantgroup.xyqb.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* 所有数据库实体,都要继承 BaseEntity
* 1. 统一的 ID 设计。
* 2. 统一的创建和更新时间。
*/
@MappedSuperclass
@Data
public abstract class BaseEntity implements Serializable {
private static final long serialVersionUID = -1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
private Long id;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
@PrePersist
public void prePersist() {
Timestamp now = new Timestamp(System.currentTimeMillis());
this.createdAt = now;
this.updatedAt = now;
}
@PreUpdate
public void preUpdate() {
this.updatedAt = new Timestamp(System.currentTimeMillis());
}
}
package cn.quantgroup.xyqb.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* Created by FrankChow on 15/7/8.
*/
@Entity
@Table(name = "channel", uniqueConstraints = @UniqueConstraint(columnNames = "channel_code"))
public class Channel implements Serializable {
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//渠道代号
@Column(name = "channel_code")
private String channelCode;
//渠道名称
@Column(name = "name")
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getChannelCode() {
return channelCode;
}
public void setChannelCode(String channelCode) {
this.channelCode = channelCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Channel{" +
"channelCode='" + channelCode + '\'' +
", id=" + id +
", name='" + name + '\'' +
'}';
}
}
...@@ -27,13 +27,9 @@ import java.sql.Timestamp; ...@@ -27,13 +27,9 @@ import java.sql.Timestamp;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class Contact implements Serializable { public class Contact extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
@Column(name = "name") @Column(name = "name")
...@@ -44,10 +40,6 @@ public class Contact implements Serializable { ...@@ -44,10 +40,6 @@ public class Contact implements Serializable {
private BizType bizType; private BizType bizType;
@Column(name = "relation") @Column(name = "relation")
private Relation relation; private Relation relation;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updateAt;
/** /**
* 数据合法性校验 * 数据合法性校验
......
...@@ -4,10 +4,8 @@ import lombok.Data; ...@@ -4,10 +4,8 @@ import lombok.Data;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
* Created by 11 on 2016/12/30. * Created by 11 on 2016/12/30.
...@@ -15,18 +13,11 @@ import java.sql.Timestamp; ...@@ -15,18 +13,11 @@ import java.sql.Timestamp;
@Data @Data
@Entity @Entity
@Table(name = "merchant") @Table(name = "merchant")
public class Merchant implements Serializable { public class Merchant extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
private Long id;
@Column(name = "name") @Column(name = "name")
private String name; private String name;
@Column(name = "enable") @Column(name = "enable")
private boolean enable; private boolean enable;
@Column(name = "created_at")
private Timestamp createAt;
@Column(name = "updated_at")
private Timestamp updateAt;
} }
...@@ -4,10 +4,8 @@ import lombok.Data; ...@@ -4,10 +4,8 @@ import lombok.Data;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
* Created by 11 on 2016/12/30. * Created by 11 on 2016/12/30.
...@@ -15,20 +13,13 @@ import java.sql.Timestamp; ...@@ -15,20 +13,13 @@ import java.sql.Timestamp;
@Data @Data
@Entity @Entity
@Table(name = "merchant_config") @Table(name = "merchant_config")
public class MerchantConfig implements Serializable { public class MerchantConfig extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
private Long id;
@Column(name = "merchant_id") @Column(name = "merchant_id")
private Long merchantId; private Long merchantId;
@Column(name = "config_name") @Column(name = "config_name")
private String configName; private String configName;
@Column(name = "config_value") @Column(name = "config_value")
private String configValue; private String configValue;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updateAt;
} }
...@@ -3,9 +3,10 @@ package cn.quantgroup.xyqb.entity; ...@@ -3,9 +3,10 @@ package cn.quantgroup.xyqb.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* Date: 2019/11/4 * Date: 2019/11/4
...@@ -16,15 +17,10 @@ import java.util.Date; ...@@ -16,15 +17,10 @@ import java.util.Date;
@Data @Data
@Entity @Entity
@Table(name = "user_modify_phone_no") @Table(name = "user_modify_phone_no")
public class ModifyPhoneNo implements Serializable { @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
public class ModifyPhoneNo extends BaseEntity implements Serializable {
private static final long serialVersionUID = -7797532159380593454L; private static final long serialVersionUID = -7797532159380593454L;
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/** /**
* user.id * user.id
...@@ -90,18 +86,4 @@ public class ModifyPhoneNo implements Serializable { ...@@ -90,18 +86,4 @@ public class ModifyPhoneNo implements Serializable {
*/ */
@Column(name = "processing_status") @Column(name = "processing_status")
private Integer processingStatus; private Integer processingStatus;
/**
*
*/
@Column(name = "created_at")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdAt;
/**
*
*/
@Column(name = "updated_at")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedAt;
} }
package cn.quantgroup.xyqb.entity; package cn.quantgroup.xyqb.entity;
import cn.quantgroup.xyqb.config.http.Timestamp2LongConverter;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import javax.persistence.*; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -18,15 +18,11 @@ import java.util.Objects; ...@@ -18,15 +18,11 @@ import java.util.Objects;
@Setter @Setter
@ToString @ToString
@Entity @Entity
@Table(name = "user", uniqueConstraints = @UniqueConstraint(columnNames = "phone_no")) @Table(name = "user",
public class User implements Serializable { uniqueConstraints = @UniqueConstraint(columnNames = "phone_no"))
public class User extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//手机号 //手机号
@Column(name = "phone_no") @Column(name = "phone_no")
private String phoneNo; private String phoneNo;
...@@ -35,7 +31,6 @@ public class User implements Serializable { ...@@ -35,7 +31,6 @@ public class User implements Serializable {
@Column(name = "password") @Column(name = "password")
private String password; private String password;
//第一次用户来源 channel_id //第一次用户来源 channel_id
@Column(name = "registered_from") @Column(name = "registered_from")
private Long registeredFrom; private Long registeredFrom;
...@@ -47,17 +42,9 @@ public class User implements Serializable { ...@@ -47,17 +42,9 @@ public class User implements Serializable {
@Column(name = "enable") @Column(name = "enable")
private Boolean enable; private Boolean enable;
//创建时间
@Column(name = "created_at")
private Timestamp createdAt;
//上一次修改时间
@Column(name = "updated_at")
@JSONField(serializeUsing = Timestamp2LongConverter.class)
private Timestamp updatedAt;
/** /**
* 是否有密码 * 是否有密码
*
* @return * @return
*/ */
public boolean getHasPassword() { public boolean getHasPassword() {
......
...@@ -12,19 +12,11 @@ import java.sql.Timestamp; ...@@ -12,19 +12,11 @@ import java.sql.Timestamp;
@Data @Data
@Entity @Entity
@Table(name = "user_attached") @Table(name = "user_attached")
public class UserAttached implements Serializable { public class UserAttached extends BaseEntity implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
@Column(name = "avatar") @Column(name = "avatar")
private String avatar; private String avatar;
@Column(name = "nick") @Column(name = "nick")
private String nick; private String nick;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
} }
package cn.quantgroup.xyqb.entity; package cn.quantgroup.xyqb.entity;
import cn.quantgroup.xyqb.config.http.Timestamp2LongConverter;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import javax.persistence.*; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
* Created by Administrator on 2017/5/16. * Created by Administrator on 2017/5/16.
...@@ -18,14 +17,9 @@ import java.sql.Timestamp; ...@@ -18,14 +17,9 @@ import java.sql.Timestamp;
@ToString @ToString
@Entity @Entity
@Table(name = "user_bt_register") @Table(name = "user_bt_register")
public class UserBtRegister implements Serializable { public class UserBtRegister extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
...@@ -34,29 +28,4 @@ public class UserBtRegister implements Serializable { ...@@ -34,29 +28,4 @@ public class UserBtRegister implements Serializable {
@Column(name = "is_active") @Column(name = "is_active")
private Boolean isActive = Boolean.TRUE; private Boolean isActive = Boolean.TRUE;
//创建时间
@Column(name = "created_at")
private Timestamp createdAt;
//上一次修改时间
@Column(name = "updated_at")
@JSONField(serializeUsing = Timestamp2LongConverter.class)
private Timestamp updatedAt;
@PrePersist
public void prePersist() {
Timestamp now = new Timestamp(System.currentTimeMillis());
this.createdAt = now;
this.updatedAt = now;
}
@PreUpdate
public void preUpdate() {
Timestamp now = new Timestamp(System.currentTimeMillis());
this.createdAt = now;
this.updatedAt = now;
}
} }
...@@ -7,7 +7,10 @@ import lombok.Getter; ...@@ -7,7 +7,10 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import javax.persistence.*; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Optional; import java.util.Optional;
...@@ -19,16 +22,12 @@ import java.util.Optional; ...@@ -19,16 +22,12 @@ import java.util.Optional;
@Setter @Setter
@ToString @ToString
@Entity @Entity
@Table(name = "user_detail", uniqueConstraints = @UniqueConstraint(columnNames = "user_id")) @Table(name = "user_detail",
public class UserDetail implements Serializable { uniqueConstraints = @UniqueConstraint(columnNames = "user_id"))
public class UserDetail extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
...@@ -60,14 +59,6 @@ public class UserDetail implements Serializable { ...@@ -60,14 +59,6 @@ public class UserDetail implements Serializable {
@Column(name = "qq") @Column(name = "qq")
private String qq; private String qq;
//创建时间
@Column(name = "created_at")
private Timestamp createdAt;
//上一次修改时间
@Column(name = "updated_at")
private Timestamp updatedAt;
public XUserDetail toXUserDetail() { public XUserDetail toXUserDetail() {
XUserDetail xUserDetail = new XUserDetail(); XUserDetail xUserDetail = new XUserDetail();
xUserDetail.setId(this.getId()); xUserDetail.setId(this.getId());
...@@ -76,10 +67,13 @@ public class UserDetail implements Serializable { ...@@ -76,10 +67,13 @@ public class UserDetail implements Serializable {
xUserDetail.setName(this.getName()); xUserDetail.setName(this.getName());
xUserDetail.setIdNo(this.getIdNo()); xUserDetail.setIdNo(this.getIdNo());
if (this.getIdType() != null) { if (this.getIdType() != null) {
xUserDetail.setIdType(cn.quantgroup.motan.enums.IdType.valueOf(this.getIdType().name())); xUserDetail.setIdType(cn.quantgroup.motan.enums.IdType.valueOf(this.getIdType()
.name()));
} }
if (this.getGender() != null) { if (this.getGender() != null) {
xUserDetail.setGender(cn.quantgroup.motan.enums.Gender.valueOf(Optional.ofNullable(this.getGender()).orElse(Gender.UNKNOWN).name())); xUserDetail.setGender(cn.quantgroup.motan.enums.Gender.valueOf(Optional.ofNullable(this.getGender())
.orElse(Gender.UNKNOWN)
.name()));
} }
xUserDetail.setEmail(this.getEmail()); xUserDetail.setEmail(this.getEmail());
xUserDetail.setQq(this.getQq()); xUserDetail.setQq(this.getQq());
...@@ -90,5 +84,4 @@ public class UserDetail implements Serializable { ...@@ -90,5 +84,4 @@ public class UserDetail implements Serializable {
return xUserDetail; return xUserDetail;
} }
} }
...@@ -14,13 +14,9 @@ import java.sql.Timestamp; ...@@ -14,13 +14,9 @@ import java.sql.Timestamp;
@Data @Data
@Entity @Entity
@Table(name = "user_ext_info") @Table(name = "user_ext_info")
public class UserExtInfo implements Serializable { public class UserExtInfo extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
@Column(name = "means_of_income_payment") @Column(name = "means_of_income_payment")
...@@ -41,14 +37,10 @@ public class UserExtInfo implements Serializable { ...@@ -41,14 +37,10 @@ public class UserExtInfo implements Serializable {
private Boolean hasCreditCard = false; private Boolean hasCreditCard = false;
@Column(name = "marry_status") @Column(name = "marry_status")
private MaritalStatus marryStatus = MaritalStatus.UNKNOWN; private MaritalStatus marryStatus = MaritalStatus.UNKNOWN;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updateAt;
public XUserExtInfo toXUserExtInfo() { public XUserExtInfo toXUserExtInfo() {
XUserExtInfo xUserExtInfo = new XUserExtInfo(); XUserExtInfo xUserExtInfo = new XUserExtInfo();
xUserExtInfo.setId(this.id); xUserExtInfo.setId(getId());
xUserExtInfo.setUserId(this.userId); xUserExtInfo.setUserId(this.userId);
xUserExtInfo.setEducationEnum(cn.quantgroup.motan.enums.EducationEnum.valueOf(this.educationEnum.name())); xUserExtInfo.setEducationEnum(cn.quantgroup.motan.enums.EducationEnum.valueOf(this.educationEnum.name()));
xUserExtInfo.setIncomeEnum(cn.quantgroup.motan.enums.IncomeEnum.valueOf(this.incomeEnum.name())); xUserExtInfo.setIncomeEnum(cn.quantgroup.motan.enums.IncomeEnum.valueOf(this.incomeEnum.name()));
...@@ -58,8 +50,8 @@ public class UserExtInfo implements Serializable { ...@@ -58,8 +50,8 @@ public class UserExtInfo implements Serializable {
xUserExtInfo.setHasSocialSecurity(this.hasSocialSecurity); xUserExtInfo.setHasSocialSecurity(this.hasSocialSecurity);
xUserExtInfo.setHasCreditCard(this.hasCreditCard); xUserExtInfo.setHasCreditCard(this.hasCreditCard);
xUserExtInfo.setMarryStatus(cn.quantgroup.motan.enums.MaritalStatus.valueOf(this.marryStatus.name())); xUserExtInfo.setMarryStatus(cn.quantgroup.motan.enums.MaritalStatus.valueOf(this.marryStatus.name()));
xUserExtInfo.setCreatedAt(this.createdAt); xUserExtInfo.setCreatedAt(getCreatedAt());
xUserExtInfo.setUpdateAt(this.updateAt); xUserExtInfo.setUpdateAt(getUpdatedAt());
return xUserExtInfo; return xUserExtInfo;
} }
} }
...@@ -12,18 +12,13 @@ import java.sql.Timestamp; ...@@ -12,18 +12,13 @@ import java.sql.Timestamp;
@Entity @Entity
@Table(name = "user_hash_mapping") @Table(name = "user_hash_mapping")
@NoArgsConstructor @NoArgsConstructor
public class UserHashMapping implements Serializable { public class UserHashMapping extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
public UserHashMapping(Long userId) { public UserHashMapping(Long userId) {
this.userId = userId; this.userId = userId;
} }
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
...@@ -39,25 +34,6 @@ public class UserHashMapping implements Serializable { ...@@ -39,25 +34,6 @@ public class UserHashMapping implements Serializable {
@Column(name = "id_no_md5_short") @Column(name = "id_no_md5_short")
private Long idNoMd5Short; private Long idNoMd5Short;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
@PrePersist
public void prePersist() {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
createdAt = timestamp;
updatedAt = timestamp;
}
@PreUpdate
public void preUpdate() {
updatedAt = new Timestamp(System.currentTimeMillis());
}
public void setPhoneNoMd5(String phoneNoMd5) { public void setPhoneNoMd5(String phoneNoMd5) {
this.phoneNoMd5 = phoneNoMd5; this.phoneNoMd5 = phoneNoMd5;
this.phoneNoMd5Short = HashUtil.crc32(phoneNoMd5); this.phoneNoMd5Short = HashUtil.crc32(phoneNoMd5);
......
...@@ -8,19 +8,12 @@ import java.sql.Timestamp; ...@@ -8,19 +8,12 @@ import java.sql.Timestamp;
@Data @Data
@Entity @Entity
@Table(name = "user_hash_phone_no_id_no_mapping") @Table(name = "user_hash_phone_no_id_no_mapping")
public class UserHashPhoneNoIdNoMapping { public class UserHashPhoneNoIdNoMapping extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
@Column(name = "phone_no_id_no_md5") @Column(name = "phone_no_id_no_md5")
private String phoneNoIdNoMd5; private String phoneNoIdNoMd5;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
public UserHashPhoneNoIdNoMapping() { public UserHashPhoneNoIdNoMapping() {
} }
...@@ -28,16 +21,4 @@ public class UserHashPhoneNoIdNoMapping { ...@@ -28,16 +21,4 @@ public class UserHashPhoneNoIdNoMapping {
public UserHashPhoneNoIdNoMapping(Long userId) { public UserHashPhoneNoIdNoMapping(Long userId) {
this.userId = userId; this.userId = userId;
} }
@PrePersist
public void prePersist() {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
createdAt = timestamp;
updatedAt = timestamp;
}
@PreUpdate
public void preUpdate() {
updatedAt = new Timestamp(System.currentTimeMillis());
}
} }
package cn.quantgroup.xyqb.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author mengfan.feng
* @time 2015-09-10 15:32
*/
@Entity
@Table(name = "user_jr58", uniqueConstraints = @UniqueConstraint(columnNames = "user_id"))
@Getter
@Setter
@ToString
public class UserJr58 implements Serializable {
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id")
private Long userId;
@Column(name = "wb_id")
private String wbId;
@Column(name = "wb_user_name")
private String wbUserName;
@Column(name = "customer_id")
private String customerId;
@Column(name = "name")
private String name;
@Column(name = "id_card")
private String idcard;
@Column(name = "email")
private String email;
@Column(name = "phone")
private String phone;
@Column(name = "info")
private String info;
@Column(name = "role_id")
private String roleId;
@Column(name = "flag")
private String flag;
@Column(name = "city")
private String city;
@Column(name = "access_mode")
private String accessMode;
@Column(name = "app_id")
private String appId;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
@Column(name = "edu")
private String edu;
@Column(name = "income")
private String income;
@Column(name = "marry")
private String marry;
}
package cn.quantgroup.xyqb.entity; package cn.quantgroup.xyqb.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.sql.Timestamp;
/** /**
* Created by 11 on 2016/12/30. * Created by 11 on 2016/12/30.
...@@ -16,11 +24,11 @@ import java.util.Date; ...@@ -16,11 +24,11 @@ import java.util.Date;
public class UserQueryLog implements Serializable { public class UserQueryLog implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id @Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
private Long id; private Long id;
@Column(name = "login_user_name") @Column(name = "login_user_name")
private String loginUserName; private String loginUserName;
@Column(name = "query_condition") @Column(name = "query_condition")
...@@ -31,10 +39,16 @@ public class UserQueryLog implements Serializable { ...@@ -31,10 +39,16 @@ public class UserQueryLog implements Serializable {
private Long resultAmount; private Long resultAmount;
@Column(name = "query_detail") @Column(name = "query_detail")
private String queryDetail; private String queryDetail;
@Column(name = "created_at")
private Date createdAt = new Date();
@Transient @Transient
private String createDate; private String createDate;
@Column(name = "created_at")
private Timestamp createdAt;
@PrePersist
public void prePersist() {
Timestamp now = new Timestamp(System.currentTimeMillis());
this.createdAt = now;
}
} }
...@@ -16,13 +16,9 @@ import java.sql.Timestamp; ...@@ -16,13 +16,9 @@ import java.sql.Timestamp;
@Setter @Setter
@ToString @ToString
@NoArgsConstructor @NoArgsConstructor
public class UserSpouse implements Serializable { public class UserSpouse extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
...@@ -33,12 +29,6 @@ public class UserSpouse implements Serializable { ...@@ -33,12 +29,6 @@ public class UserSpouse implements Serializable {
@Column(name = "spouse_name") @Column(name = "spouse_name")
private String spouseName; private String spouseName;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updateAt;
@Column(name = "status") @Column(name = "status")
private MaritalStatus status; private MaritalStatus status;
......
...@@ -15,13 +15,9 @@ import java.sql.Timestamp; ...@@ -15,13 +15,9 @@ import java.sql.Timestamp;
@Entity @Entity
@Table(name = "wechat_userinfo") @Table(name = "wechat_userinfo")
@Data @Data
public class WechatUserInfo implements Serializable { public class WechatUserInfo extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id") @Column(name = "user_id")
private Long userId; private Long userId;
@Column(name = "open_id") @Column(name = "open_id")
...@@ -42,10 +38,6 @@ public class WechatUserInfo implements Serializable { ...@@ -42,10 +38,6 @@ public class WechatUserInfo implements Serializable {
private String country; private String country;
@Column(name = "head_img_url") @Column(name = "head_img_url")
private String headImgUrl; private String headImgUrl;
@Column(name = "created_at")
private Timestamp createdAt = new Timestamp(System.currentTimeMillis());
@Column(name = "updated_at")
private Timestamp updatedAt = new Timestamp(System.currentTimeMillis());
public WechatUserInfo convertEmoji() { public WechatUserInfo convertEmoji() {
......
...@@ -30,9 +30,6 @@ public class AddressRegisteredEventListener implements ApplicationListener<Regis ...@@ -30,9 +30,6 @@ public class AddressRegisteredEventListener implements ApplicationListener<Regis
} }
User user = userRegisterParam.getUser(); User user = userRegisterParam.getUser();
address.setUserId(user.getId()); address.setUserId(user.getId());
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
address.setCreatedAt(currentTime);
address.setUpdateAt(currentTime);
addressRepository.save(address); addressRepository.save(address);
} }
} }
...@@ -36,9 +36,6 @@ public class BtRegisteredEventListener implements ApplicationListener<RegisterEv ...@@ -36,9 +36,6 @@ public class BtRegisteredEventListener implements ApplicationListener<RegisterEv
userBtRegister.setRegisterBtMerchantId(btRegisterChannelId); userBtRegister.setRegisterBtMerchantId(btRegisterChannelId);
} }
userBtRegister.setIsActive(true); userBtRegister.setIsActive(true);
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
userBtRegister.setCreatedAt(currentTime);
userBtRegister.setUpdatedAt(currentTime);
userBtRegisterService.save(userBtRegister); userBtRegisterService.save(userBtRegister);
} }
} }
...@@ -51,9 +51,6 @@ public class DetailRegisteredEventListener implements ApplicationListener<Regist ...@@ -51,9 +51,6 @@ public class DetailRegisteredEventListener implements ApplicationListener<Regist
userDetail.setPhoneNo(phoneNo); userDetail.setPhoneNo(phoneNo);
userDetail.setName(name); userDetail.setName(name);
userDetail.setIdType(IdType.ID_CARD); userDetail.setIdType(IdType.ID_CARD);
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
userDetail.setCreatedAt(currentTime);
userDetail.setUpdatedAt(currentTime);
userDetail.setUserId(user.getId()); userDetail.setUserId(user.getId());
userDetail.setGender(cardInfo.getGender()); userDetail.setGender(cardInfo.getGender());
userDetailService.saveUserDetail(userDetail); userDetailService.saveUserDetail(userDetail);
......
package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.webchat.WechatEventMsg;
import cn.quantgroup.xyqb.repository.IUserRepository;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
/**
* 微信绑定关系变动。通知某系统
*/
@Slf4j
@Component
public class NotifyWechatBindEventListener implements ApplicationListener<WechatBindEvent> {
@Resource
private RabbitTemplate wechatRabbitTemplate;
@Resource
private IUserRepository userRepository;
@Override
public void onApplicationEvent(WechatBindEvent event) {
WechatEventMsg wechatEventMsg = event.getWechatEventMsg();
if (wechatEventMsg.getUserId() == null) {
log.info("微信绑定数据,没有用户 ID 信息,openId:{}", wechatEventMsg.getOpenId());
return;
}
User user = userRepository.findById(wechatEventMsg.getUserId());
if (user == null) {
log.info("微信绑定数据,没有用户信息,openId:{},userId:{}", wechatEventMsg.getOpenId(), wechatEventMsg.getUserId());
return;
}
String uuid = user.getUuid();
Map<String, Object> msg = Maps.newHashMapWithExpectedSize(3);
msg.put("uuid", uuid);
msg.put("openId", wechatEventMsg.getOpenId());
msg.put("timestamp", event.getTimestamp());
wechatRabbitTemplate.convertAndSend(msg);
}
}
package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.model.webchat.WechatEventMsg;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationEvent;
/**
* 微信用户绑定信息创建或更新事件
*
* @author ag
*/
@Getter
@Setter
public class WechatBindEvent extends ApplicationEvent {
private WechatEventMsg wechatEventMsg;
/**
* Create a new ApplicationEvent.
*
* @param source the object on which the event initially occurred (never {@code null})
*/
public WechatBindEvent(Object source) {
super(source);
}
public WechatBindEvent(Object source, WechatEventMsg wechatEventMsg) {
super(source);
this.wechatEventMsg = wechatEventMsg;
}
}
...@@ -37,7 +37,7 @@ public class AddressRet { ...@@ -37,7 +37,7 @@ public class AddressRet {
ret.setCity(address.getCity()); ret.setCity(address.getCity());
ret.setAddress(address.getAddress()); ret.setAddress(address.getAddress());
ret.setCreatedAt(address.getCreatedAt().getTime()); ret.setCreatedAt(address.getCreatedAt().getTime());
ret.setUpdateAt(address.getUpdateAt().getTime()); ret.setUpdateAt(address.getUpdatedAt().getTime());
return ret; return ret;
} }
} }
...@@ -40,8 +40,8 @@ public class ContactRet implements Serializable { ...@@ -40,8 +40,8 @@ public class ContactRet implements Serializable {
if(Objects.nonNull(c.getCreatedAt())){ if(Objects.nonNull(c.getCreatedAt())){
ret.setCreatedAt(c.getCreatedAt().getTime()); ret.setCreatedAt(c.getCreatedAt().getTime());
} }
if(Objects.nonNull(c.getUpdateAt())) { if(Objects.nonNull(c.getUpdatedAt())) {
ret.setUpdateAt(c.getUpdateAt().getTime()); ret.setUpdateAt(c.getUpdatedAt().getTime());
} }
return ret; return ret;
} }
......
...@@ -46,7 +46,7 @@ public class UserExtInfoRet { ...@@ -46,7 +46,7 @@ public class UserExtInfoRet {
ret.setHasCreditCard(defaultBoolean(extInfo.getHasCreditCard())); ret.setHasCreditCard(defaultBoolean(extInfo.getHasCreditCard()));
ret.setMarryStatus(extInfo.getMarryStatus()); ret.setMarryStatus(extInfo.getMarryStatus());
ret.setCreatedAt(extInfo.getCreatedAt().getTime()); ret.setCreatedAt(extInfo.getCreatedAt().getTime());
ret.setUpdateAt(extInfo.getUpdateAt().getTime()); ret.setUpdateAt(extInfo.getUpdatedAt().getTime());
return ret; return ret;
} }
} }
...@@ -30,8 +30,8 @@ public class UserSpouseRet { ...@@ -30,8 +30,8 @@ public class UserSpouseRet {
ret.setUserId(userSpouse.getUserId()); ret.setUserId(userSpouse.getUserId());
ret.setSpouseName(userSpouse.getSpouseName()); ret.setSpouseName(userSpouse.getSpouseName());
ret.setSpousePhone(userSpouse.getSpousePhone()); ret.setSpousePhone(userSpouse.getSpousePhone());
if (userSpouse.getUpdateAt() != null) { if (userSpouse.getUpdatedAt() != null) {
ret.setUpdateAt(userSpouse.getUpdateAt().getTime()); ret.setUpdateAt(userSpouse.getUpdatedAt().getTime());
} }
if (userSpouse.getCreatedAt() != null) { if (userSpouse.getCreatedAt() != null) {
ret.setCreatedAt(userSpouse.getCreatedAt().getTime()); ret.setCreatedAt(userSpouse.getCreatedAt().getTime());
......
package cn.quantgroup.xyqb.model.webchat;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class WechatEventMsg {
private Long userId;
private String openId;
}
package cn.quantgroup.xyqb.repository;
import cn.quantgroup.xyqb.entity.Channel;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author mengfan.feng
* @time 2015-09-11 11:25
*/
public interface IChannelRepository extends JpaRepository<Channel, Long> {
}
package cn.quantgroup.xyqb.repository;
import cn.quantgroup.xyqb.entity.UserJr58;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author mengfan.feng
* @time 2015-09-11 14:35
*/
public interface IUserJr58Repository extends JpaRepository<UserJr58, Long> {
}
...@@ -34,7 +34,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -34,7 +34,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Resource @Resource
private IUserRepository userRepository; private IUserRepository userRepository;
@Cacheable(value = "user_authorized_idno_cache", key = "#idNo", unless = "#result == false", cacheManager = "cacheManager") // @Cacheable(value = "user_authorized_idno_cache", key = "#idNo", unless = "#result == false", cacheManager = "cacheManager")
@Override @Override
public Boolean hasUserAuthorized(String idNo) { public Boolean hasUserAuthorized(String idNo) {
try { try {
...@@ -81,9 +81,6 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -81,9 +81,6 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
userAuthorized.setName(userAuthorizedParam.getName()); userAuthorized.setName(userAuthorizedParam.getName());
userAuthorized.setIdNo(userAuthorizedParam.getIdNo()); userAuthorized.setIdNo(userAuthorizedParam.getIdNo());
userAuthorized.setUserUuid(userAuthorizedParam.getUserUuid()); userAuthorized.setUserUuid(userAuthorizedParam.getUserUuid());
Timestamp now = new Timestamp(System.currentTimeMillis());
userAuthorized.setCreatedAt(now);
userAuthorized.setUpdatedAt(now);
try { try {
userAuthorized = userAuthorizedRepository.save(userAuthorized); userAuthorized = userAuthorizedRepository.save(userAuthorized);
...@@ -95,7 +92,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -95,7 +92,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
} }
} }
@Cacheable(value = "user_authorized_uuid_2_id_cache", key = "#userUuid", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "user_authorized_uuid_2_id_cache", key = "#userUuid", unless = "#result == null", cacheManager = "cacheManager")
@Override @Override
public String getUserAuthorizedId(String userUuid) { public String getUserAuthorizedId(String userUuid) {
if (StringUtils.isBlank(userUuid)) { if (StringUtils.isBlank(userUuid)) {
......
...@@ -94,9 +94,6 @@ public class UserRegisterServiceImpl implements IUserRegisterService { ...@@ -94,9 +94,6 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
if (StringUtils.isNotBlank(password)) { if (StringUtils.isNotBlank(password)) {
user.setPassword(PasswordUtil.MD5WithSalt(password)); user.setPassword(PasswordUtil.MD5WithSalt(password));
} }
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
user.setUpdatedAt(currentTime);
user.setCreatedAt(currentTime);
user = userService.saveUser(user); user = userService.saveUser(user);
userRegisterParam.setUser(user); userRegisterParam.setUser(user);
return user; return user;
......
...@@ -22,7 +22,7 @@ public class AddressServiceImpl implements IAddressService { ...@@ -22,7 +22,7 @@ public class AddressServiceImpl implements IAddressService {
private IAddressRepository addressRepository; private IAddressRepository addressRepository;
@Override @Override
@Cacheable(value = "addresscache", key = "'address' + #userId", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "addresscache", key = "'address' + #userId", unless = "#result == null", cacheManager = "cacheManager")
public Address findByUserId(Long userId) { public Address findByUserId(Long userId) {
return addressRepository.findByUserId(userId); return addressRepository.findByUserId(userId);
} }
...@@ -30,14 +30,11 @@ public class AddressServiceImpl implements IAddressService { ...@@ -30,14 +30,11 @@ public class AddressServiceImpl implements IAddressService {
@Override @Override
@CacheEvict(value = "addresscache", key = "'address' + #addressObj.userId", cacheManager = "cacheManager") @CacheEvict(value = "addresscache", key = "'address' + #addressObj.userId", cacheManager = "cacheManager")
public Address save(Address addressObj) { public Address save(Address addressObj) {
Timestamp now = new Timestamp(System.currentTimeMillis());
/* 替换所有,UTF-8编码时4字节的Emoji表情字符 */ /* 替换所有,UTF-8编码时4字节的Emoji表情字符 */
addressObj.setProvince(EmojiUtil.filterUnicode4(addressObj.getProvince())); addressObj.setProvince(EmojiUtil.filterUnicode4(addressObj.getProvince()));
addressObj.setCity(EmojiUtil.filterUnicode4(addressObj.getCity())); addressObj.setCity(EmojiUtil.filterUnicode4(addressObj.getCity()));
addressObj.setDistrict(EmojiUtil.filterUnicode4(addressObj.getDistrict())); addressObj.setDistrict(EmojiUtil.filterUnicode4(addressObj.getDistrict()));
addressObj.setAddress(EmojiUtil.filterUnicode4(addressObj.getAddress())); addressObj.setAddress(EmojiUtil.filterUnicode4(addressObj.getAddress()));
addressObj.setCreatedAt(now);
addressObj.setUpdateAt(now);
return addressRepository.save(addressObj); return addressRepository.save(addressObj);
} }
......
...@@ -84,8 +84,6 @@ public class ContactServiceImpl implements IContactService { ...@@ -84,8 +84,6 @@ public class ContactServiceImpl implements IContactService {
contact.setRelation(relation); contact.setRelation(relation);
} }
log.info("修改前联系人信息:{}", contact); log.info("修改前联系人信息:{}", contact);
Timestamp now = new Timestamp(System.currentTimeMillis());
contact.setUpdateAt(now);
contact = save(contact); contact = save(contact);
return contact; return contact;
} }
...@@ -109,7 +107,6 @@ public class ContactServiceImpl implements IContactService { ...@@ -109,7 +107,6 @@ public class ContactServiceImpl implements IContactService {
private void mergeContacts(Long userId, List<Contact> contacts) { private void mergeContacts(Long userId, List<Contact> contacts) {
// 当前联系人列表 // 当前联系人列表
List<Contact> userContact = contactRepository.findByUserId(userId); List<Contact> userContact = contactRepository.findByUserId(userId);
Timestamp now = new Timestamp(System.currentTimeMillis());
for (int i = 0; i < contacts.size(); i++) { for (int i = 0; i < contacts.size(); i++) {
Contact c = contacts.get(i); Contact c = contacts.get(i);
c.setId(null); c.setId(null);
...@@ -117,8 +114,6 @@ public class ContactServiceImpl implements IContactService { ...@@ -117,8 +114,6 @@ public class ContactServiceImpl implements IContactService {
if(Objects.isNull(c.getRelation())){ if(Objects.isNull(c.getRelation())){
c.setRelation(Relation.OTHER); c.setRelation(Relation.OTHER);
} }
c.setCreatedAt(now);
c.setUpdateAt(now);
if (CollectionUtils.isEmpty(userContact) || userContact.size() <= i) { if (CollectionUtils.isEmpty(userContact) || userContact.size() <= i) {
continue; continue;
} }
......
...@@ -191,7 +191,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService { ...@@ -191,7 +191,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
throw new DataException("数据不存在。"); throw new DataException("数据不存在。");
} }
modifyPhoneNo.setProcessingStatus(ModifyPhoneNoProcessingStatusEnum.DONE.ordinal()); modifyPhoneNo.setProcessingStatus(ModifyPhoneNoProcessingStatusEnum.DONE.ordinal());
modifyPhoneNo.setUpdatedAt(new Date());
} }
@Override @Override
...@@ -205,7 +204,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService { ...@@ -205,7 +204,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
modifyPhoneNo.setApplyStatus(ModifyPhoneNoApplyStatusEnum.NO_ALLOW.ordinal()); modifyPhoneNo.setApplyStatus(ModifyPhoneNoApplyStatusEnum.NO_ALLOW.ordinal());
modifyPhoneNo.setApplyStatusReason(auditReq.getApplyStatusReason()); modifyPhoneNo.setApplyStatusReason(auditReq.getApplyStatusReason());
modifyPhoneNo.setProcessingStatus(ModifyPhoneNoProcessingStatusEnum.WAIT_4_USER_FEEDBACK.ordinal()); modifyPhoneNo.setProcessingStatus(ModifyPhoneNoProcessingStatusEnum.WAIT_4_USER_FEEDBACK.ordinal());
modifyPhoneNo.setUpdatedAt(new Date());
} }
if (ModifyPhoneNoApplyStatusEnum.DONE == auditReq.getApplyStatus()) { if (ModifyPhoneNoApplyStatusEnum.DONE == auditReq.getApplyStatus()) {
log.info("audit userId = 【{}】, name = 【{}】, idCard = 【{}】, prevPhoneNo = 【{}】, " + log.info("audit userId = 【{}】, name = 【{}】, idCard = 【{}】, prevPhoneNo = 【{}】, " +
...@@ -220,7 +218,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService { ...@@ -220,7 +218,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
userService.modifyPhoneNo(modifyPhoneNo.getPrevPhoneNo(), modifyPhoneNo.getCurPhoneNo()); userService.modifyPhoneNo(modifyPhoneNo.getPrevPhoneNo(), modifyPhoneNo.getCurPhoneNo());
modifyPhoneNo.setApplyStatus(ModifyPhoneNoApplyStatusEnum.DONE.ordinal()); modifyPhoneNo.setApplyStatus(ModifyPhoneNoApplyStatusEnum.DONE.ordinal());
modifyPhoneNo.setProcessingStatus(ModifyPhoneNoProcessingStatusEnum.WAIT_4_USER_FEEDBACK.ordinal()); modifyPhoneNo.setProcessingStatus(ModifyPhoneNoProcessingStatusEnum.WAIT_4_USER_FEEDBACK.ordinal());
modifyPhoneNo.setUpdatedAt(new Date());
} }
} }
......
...@@ -20,7 +20,7 @@ public class UserBtRegisterServiceImpl implements IUserBtRegisterService { ...@@ -20,7 +20,7 @@ public class UserBtRegisterServiceImpl implements IUserBtRegisterService {
private IUserBtRegisterRepository userBtRegisterRepository; private IUserBtRegisterRepository userBtRegisterRepository;
@Override @Override
@Cacheable(value = "btRegisterCache", key = "'userId' + #userId", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "btRegisterCache", key = "'userId' + #userId", unless = "#result == null", cacheManager = "cacheManager")
public UserBtRegister findByUserId(Long userId) { public UserBtRegister findByUserId(Long userId) {
if (null != userId) { if (null != userId) {
return userBtRegisterRepository.findOne((root, query, cb) -> { return userBtRegisterRepository.findOne((root, query, cb) -> {
......
...@@ -28,7 +28,7 @@ public class UserCenterServiceImpl implements UserCenterService { ...@@ -28,7 +28,7 @@ public class UserCenterServiceImpl implements UserCenterService {
private IUserAttachedRepository userAttachedRepository; private IUserAttachedRepository userAttachedRepository;
@Override @Override
@Cacheable(value = "userAttachedCache", key = "'xyqbUserAttached' + #userId", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "userAttachedCache", key = "'xyqbUserAttached' + #userId", unless = "#result == null", cacheManager = "cacheManager")
public UserAttached searchUserAttachedByUserId(long userId) { public UserAttached searchUserAttachedByUserId(long userId) {
return userAttachedRepository.findByUserId(userId); return userAttachedRepository.findByUserId(userId);
} }
...@@ -47,7 +47,6 @@ public class UserCenterServiceImpl implements UserCenterService { ...@@ -47,7 +47,6 @@ public class UserCenterServiceImpl implements UserCenterService {
} }
if(!Objects.equals(avatar, userAttached.getAvatar())){ if(!Objects.equals(avatar, userAttached.getAvatar())){
userAttached.setAvatar(avatar); userAttached.setAvatar(avatar);
userAttached.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
userAttached = userAttachedRepository.save(userAttached); userAttached = userAttachedRepository.save(userAttached);
} }
return userAttached; return userAttached;
...@@ -64,7 +63,6 @@ public class UserCenterServiceImpl implements UserCenterService { ...@@ -64,7 +63,6 @@ public class UserCenterServiceImpl implements UserCenterService {
} }
if(!Objects.equals(nick, userAttached.getNick())){ if(!Objects.equals(nick, userAttached.getNick())){
userAttached.setNick(nick); userAttached.setNick(nick);
userAttached.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
try { try {
userAttached = userAttachedRepository.save(userAttached); userAttached = userAttachedRepository.save(userAttached);
}catch (ConstraintViolationException e){ }catch (ConstraintViolationException e){
...@@ -87,7 +85,6 @@ public class UserCenterServiceImpl implements UserCenterService { ...@@ -87,7 +85,6 @@ public class UserCenterServiceImpl implements UserCenterService {
UserAttached userAttached = userAttachedRepository.findByUserId(userId); UserAttached userAttached = userAttachedRepository.findByUserId(userId);
// 更新实例 // 更新实例
userAttached = Optional.ofNullable(userAttached).orElse(new UserAttached()); userAttached = Optional.ofNullable(userAttached).orElse(new UserAttached());
Timestamp now = new Timestamp(System.currentTimeMillis());
userAttached.setUserId(userId); userAttached.setUserId(userId);
if(StringUtils.isBlank(userAttached.getAvatar())){ if(StringUtils.isBlank(userAttached.getAvatar())){
userAttached.setAvatar(avatar); userAttached.setAvatar(avatar);
...@@ -95,10 +92,6 @@ public class UserCenterServiceImpl implements UserCenterService { ...@@ -95,10 +92,6 @@ public class UserCenterServiceImpl implements UserCenterService {
if(StringUtils.isBlank(userAttached.getNick())){ if(StringUtils.isBlank(userAttached.getNick())){
userAttached.setNick(nick); userAttached.setNick(nick);
} }
if(Objects.isNull(userAttached.getCreatedAt())){
userAttached.setCreatedAt(now);
}
userAttached.setUpdatedAt(now);
return userAttachedRepository.save(userAttached); return userAttachedRepository.save(userAttached);
} }
} }
...@@ -21,7 +21,7 @@ public class UserExtInfoServiceImpl implements IUserExtInfoService { ...@@ -21,7 +21,7 @@ public class UserExtInfoServiceImpl implements IUserExtInfoService {
private IUserExtInfoRepository userExtInfoRepository; private IUserExtInfoRepository userExtInfoRepository;
@Override @Override
@Cacheable(value = "userextinfocache", key = "'extinfo' + #userId", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "userextinfocache", key = "'extinfo' + #userId", unless = "#result == null", cacheManager = "cacheManager")
public UserExtInfo findByUserId(Long userId) { public UserExtInfo findByUserId(Long userId) {
return userExtInfoRepository.findByUserId(userId); return userExtInfoRepository.findByUserId(userId);
} }
...@@ -30,13 +30,6 @@ public class UserExtInfoServiceImpl implements IUserExtInfoService { ...@@ -30,13 +30,6 @@ public class UserExtInfoServiceImpl implements IUserExtInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@CacheEvict(value = "userextinfocache", key = "'extinfo' + #info.userId", cacheManager = "cacheManager") @CacheEvict(value = "userextinfocache", key = "'extinfo' + #info.userId", cacheManager = "cacheManager")
public UserExtInfo save(UserExtInfo info) { public UserExtInfo save(UserExtInfo info) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
if (info.getCreatedAt() == null) {
info.setCreatedAt(timestamp);
}
if (info.getUpdateAt() == null) {
info.setUpdateAt(timestamp);
}
return userExtInfoRepository.save(info); return userExtInfoRepository.save(info);
} }
......
...@@ -101,7 +101,7 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -101,7 +101,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
private IContactService contactService; private IContactService contactService;
@Override @Override
@Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public User findByPhoneInDb(String phone) { public User findByPhoneInDb(String phone) {
return userRepository.findByPhoneNo(phone); return userRepository.findByPhoneNo(phone);
} }
...@@ -155,13 +155,13 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -155,13 +155,13 @@ public class UserServiceImpl implements IUserService, IBaseController {
} }
@Override @Override
@Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public User findByPhoneWithCache(String phone) { public User findByPhoneWithCache(String phone) {
return userRepository.findByPhoneNo(phone); return userRepository.findByPhoneNo(phone);
} }
@Override @Override
@Cacheable(value = "usercache", key = "'xyqbuser' + #uuid", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "usercache", key = "'xyqbuser' + #uuid", unless = "#result == null", cacheManager = "cacheManager")
public User findByUuidWithCache(String uuid) { public User findByUuidWithCache(String uuid) {
return userRepository.findByUuid(uuid); return userRepository.findByUuid(uuid);
} }
...@@ -186,7 +186,6 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -186,7 +186,6 @@ public class UserServiceImpl implements IUserService, IBaseController {
if (user == null) { if (user == null) {
throw new RuntimeException("用户[" + phoneNo + "]不存在"); throw new RuntimeException("用户[" + phoneNo + "]不存在");
} }
user.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
user.setPassword(PasswordUtil.MD5WithSalt(password)); user.setPassword(PasswordUtil.MD5WithSalt(password));
user = userRepository.save(user); user = userRepository.save(user);
stringRedisTemplate.expire("usercache:xyqbuser" + phoneNo, 1L, TimeUnit.MILLISECONDS); stringRedisTemplate.expire("usercache:xyqbuser" + phoneNo, 1L, TimeUnit.MILLISECONDS);
......
...@@ -15,7 +15,7 @@ public class UserSpouseServiceImpl implements IUserSpouseService { ...@@ -15,7 +15,7 @@ public class UserSpouseServiceImpl implements IUserSpouseService {
private IUserSpouseRepository userSpouseRepository; private IUserSpouseRepository userSpouseRepository;
@Override @Override
@Cacheable(value = "userSpouseCache", key = "'spouse' + #userId", unless = "#result == null", cacheManager = "cacheManager") // @Cacheable(value = "userSpouseCache", key = "'spouse' + #userId", unless = "#result == null", cacheManager = "cacheManager")
public UserSpouse findByUserId(Long userId) { public UserSpouse findByUserId(Long userId) {
return userSpouseRepository.findByUserId(userId); return userSpouseRepository.findByUserId(userId);
} }
......
...@@ -84,7 +84,6 @@ public class UserDetailVO { ...@@ -84,7 +84,6 @@ public class UserDetailVO {
xUserDetail.setUpdatedAt(new Timestamp(this.getUpdatedAt())); xUserDetail.setUpdatedAt(new Timestamp(this.getUpdatedAt()));
} }
xUserDetail.setIsAuthenticated(this.getIsAuthenticated()); xUserDetail.setIsAuthenticated(this.getIsAuthenticated());
xUserDetail.setEnable(this.getEnable()); xUserDetail.setEnable(this.getEnable());
return xUserDetail; return xUserDetail;
......
...@@ -2,13 +2,13 @@ package cn.quantgroup.xyqb.service.wechat.impl; ...@@ -2,13 +2,13 @@ package cn.quantgroup.xyqb.service.wechat.impl;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.WechatUserInfo; import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.event.WechatBindEvent;
import cn.quantgroup.xyqb.exception.WechatRelateUserException; import cn.quantgroup.xyqb.exception.WechatRelateUserException;
import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse; import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
import cn.quantgroup.xyqb.model.webchat.WechatEventMsg;
import cn.quantgroup.xyqb.repository.IWeChatUserRepository; import cn.quantgroup.xyqb.repository.IWeChatUserRepository;
import cn.quantgroup.xyqb.service.http.IHttpService; import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.wechat.IWechatService; import cn.quantgroup.xyqb.service.wechat.IWechatService;
import cn.quantgroup.xyqb.util.EmojiUtil;
import cn.quantgroup.xyqb.util.ValidationUtil; import cn.quantgroup.xyqb.util.ValidationUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -47,6 +48,9 @@ public class WechatServiceImpl implements IWechatService { ...@@ -47,6 +48,9 @@ public class WechatServiceImpl implements IWechatService {
@Qualifier("stringRedisTemplate") @Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
@Resource
private ApplicationEventPublisher applicationEventPublisher;
@PostConstruct @PostConstruct
private void init() { private void init() {
accessTokenUrl = String.format("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&grant_type=authorization_code&code=", appId, secret) + "%s"; accessTokenUrl = String.format("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&grant_type=authorization_code&code=", appId, secret) + "%s";
...@@ -143,7 +147,13 @@ public class WechatServiceImpl implements IWechatService { ...@@ -143,7 +147,13 @@ public class WechatServiceImpl implements IWechatService {
// String city = EmojiUtil.filterUnicode4(userInfo.getCity()); // String city = EmojiUtil.filterUnicode4(userInfo.getCity());
// userInfo.setCity(city); // userInfo.setCity(city);
userInfo = userInfo.convertEmoji(); userInfo = userInfo.convertEmoji();
return weChatUserRepository.save(userInfo); WechatUserInfo wechatUserInfo = weChatUserRepository.save(userInfo);
WechatEventMsg wechatEventMsg = WechatEventMsg.builder()
.userId(wechatUserInfo.getUserId())
.openId(wechatUserInfo.getOpenId())
.build();
applicationEventPublisher.publishEvent(new WechatBindEvent(this, wechatEventMsg));
return wechatUserInfo;
} }
@Override @Override
...@@ -170,6 +180,11 @@ public class WechatServiceImpl implements IWechatService { ...@@ -170,6 +180,11 @@ public class WechatServiceImpl implements IWechatService {
log.error("微信关联失败:绑定条数<1:[service]:userId:{},phoneNo:{},openId:{}", userId, phoneNo, openId); log.error("微信关联失败:绑定条数<1:[service]:userId:{},phoneNo:{},openId:{}", userId, phoneNo, openId);
throw new WechatRelateUserException("微信关联失败"); throw new WechatRelateUserException("微信关联失败");
} }
WechatEventMsg wechatEventMsg = WechatEventMsg.builder()
.userId(userId)
.openId(openId)
.build();
applicationEventPublisher.publishEvent(new WechatBindEvent(this,wechatEventMsg));
// Todo : 如果当前openId已关联其他用户,则解绑成功后要注销其登录session -- 考虑后暂时不执行,影响太大 // Todo : 如果当前openId已关联其他用户,则解绑成功后要注销其登录session -- 考虑后暂时不执行,影响太大
log.info("微信关联成功:[service]:userId:{},phoneNo:{},openId:{},dissociate:{},relate:{},Old-WechatUserInfo:{}", userId, phoneNo, openId, dissociate, relate, wechatUserInfo); log.info("微信关联成功:[service]:userId:{},phoneNo:{},openId:{},dissociate:{},relate:{},Old-WechatUserInfo:{}", userId, phoneNo, openId, dissociate, relate, wechatUserInfo);
return relate; return relate;
......
...@@ -66,9 +66,6 @@ public class UserServiceTest { ...@@ -66,9 +66,6 @@ public class UserServiceTest {
addressObj.setProvince("悉尼"); addressObj.setProvince("悉尼");
addressObj.setProvinceCode(1L); addressObj.setProvinceCode(1L);
addressObj.setAddress("嘻哈"); addressObj.setAddress("嘻哈");
Timestamp timestamp=Timestamp.valueOf( LocalDateTime.now());
addressObj.setCreatedAt(timestamp);
addressObj.setUpdateAt(timestamp);
return Arrays.asList(new Object[][]{{addressObj}}); return Arrays.asList(new Object[][]{{addressObj}});
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment