Commit f299eba2 authored by Java—KA—李 青's avatar Java—KA—李 青

merge conflict

parents eedf9c38 e295c4ea
......@@ -13,7 +13,6 @@ public interface Constants {
String IMAGE_CAPTCHA_KEY = "img_captcha:";
String REDIS_CAPTCHA_KEY = "auth:";
String REDIS_CAPTCHA_KEY_PATTERN = REDIS_CAPTCHA_KEY + IMAGE_CAPTCHA_KEY + "*";
String CONFIG_CAPTCHA = "cfg_captcha_%";
// app 后端白名单
......
......@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
......@@ -70,12 +71,12 @@ public class RedisCaptchaStore implements CaptchaStore {
@Override
public int getSize() {
return getKeys().size();
return 0;
}
@Override
public Collection getKeys() {
return stringRedisTemplate.keys(Constants.REDIS_CAPTCHA_KEY_PATTERN);
return Collections.emptyList();
}
@Override
......
......@@ -41,6 +41,7 @@ import java.sql.Timestamp;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.stream.Collectors;
......@@ -196,6 +197,18 @@ public class MotanUserServiceImpl implements UserMotanService {
return returnErrorValue("要保存的用户详情对象不能为null");
}
UserDetail userDetail = new UserDetail();
if (!ValidationUtil.validateChinese(userDetailUpdateBean.getName())) {
return returnErrorValue("用户姓名错误");
}
IdCardInfo info = null;
try {
info = idCardService.getIdCardInfo(userDetailUpdateBean.getIdNo());
} catch (ParseException ex) {
log.error("用户身份证号错误, idNo: {}", userDetailUpdateBean.getIdNo(), ex);
}
if (Objects.isNull(info) || !info.isValid()) {
return returnErrorValue("身份证号码错误");
}
if (null != userDetailUpdateBean.getId() && userDetailUpdateBean.getId() > 0L) {
userDetail.setId(userDetailUpdateBean.getId());
}
......@@ -207,12 +220,7 @@ public class MotanUserServiceImpl implements UserMotanService {
userDetail.setCreatedAt(time);
userDetail.setUpdatedAt(time);
userDetail.setIdType(IdType.ID_CARD);
try {
userDetail.setGender(idCardService.getIdCardInfo(userDetailUpdateBean.getIdNo()).getGender());
} catch (ParseException e) {
log.error("根据身份证获取性别出错,userDetailUpdateBean:{}", JSON.toJSONString(userDetailUpdateBean), e);
return returnErrorValue("根据身份证获取性别出错.");
}
userDetail.setGender(info.getGender());
userDetail.setEmail(userDetailUpdateBean.getEmail());
userDetail = userDetailService.saveUserDetail(userDetail);
if (userDetail != null) {
......@@ -241,6 +249,18 @@ public class MotanUserServiceImpl implements UserMotanService {
if (StringUtils.isBlank(userDetailSaveBean.getIdNo())) {
return returnErrorValue("用户身份证为空");
}
if (!ValidationUtil.validateChinese(userDetailSaveBean.getName())) {
return returnErrorValue("用户姓名错误");
}
IdCardInfo info = null;
try {
info = idCardService.getIdCardInfo(userDetailSaveBean.getIdNo());
} catch (ParseException ex) {
log.error("用户身份证号错误, idNo: {}", userDetailSaveBean.getIdNo(), ex);
}
if (Objects.isNull(info) || !info.isValid()) {
return returnErrorValue("身份证号码错误");
}
Timestamp time = new Timestamp(System.currentTimeMillis());
UserDetail userDetail = userDetailService.findByUserId(userId);
if (userDetail == null) {
......@@ -251,19 +271,12 @@ public class MotanUserServiceImpl implements UserMotanService {
} else {
userDetail.setUpdatedAt(time);
}
userDetail.setName(userDetail.getName());
userDetail.setPhoneNo(userDetail.getPhoneNo());
userDetail.setName(userDetailSaveBean.getName());
userDetail.setPhoneNo(userDetailSaveBean.getPhoneNo());
userDetail.setIdType(IdType.ID_CARD);
if (StringUtils.isNotBlank(userDetail.getIdNo())) {
try {
userDetail.setGender(idCardService.getIdCardInfo(userDetail.getIdNo()).getGender());
} catch (ParseException e) {
log.error("根据身份证获取性别出错,身份证号码:{}", userDetail.getIdNo(), e);
return returnErrorValue("身份证信息出错");
}
userDetail.setIdNo(userDetail.getIdNo());
}
userDetail.setEmail(userDetail.getEmail());
userDetail.setGender(info.getGender());
userDetail.setIdNo(userDetailSaveBean.getIdNo());
userDetail.setEmail(userDetailSaveBean.getEmail());
userDetail = userDetailService.saveUserDetail(userDetail);
if (userDetail != null) {
return returnSuccessValue(fromUserDetail(userDetail));
......@@ -335,7 +348,7 @@ public class MotanUserServiceImpl implements UserMotanService {
@Override
public UserSysResult<List<XContact>> findContactsByUserId(Long userId) {
List<Contact> contacts = contactService.findByUserId(userId);
List<Contact> contacts = contactService.findByUserId(userId, true);
List<XContact> xContacts = convertObject(JSON.toJSONString(contacts), new TypeReference<List<XContact>>() {
});
return returnSuccessValue(xContacts);
......@@ -353,23 +366,19 @@ public class MotanUserServiceImpl implements UserMotanService {
String jsonContacts = JSON.toJSONString(contacts);
List<Contact> contactList = null;
try {
contactList = MAPPER.readValue(jsonContacts, new TypeReference<List<Contact>>() {
});
contactList = MAPPER.readValue(jsonContacts, new TypeReference<List<Contact>>(){});
} catch (Exception e) {
log.error("联系人列表转换错误", e);
return returnErrorValue("联系人转换错误");
}
Timestamp now = new Timestamp(System.currentTimeMillis());
for (Contact c : contactList) {
c.setId(null);
c.setUserId(userId);
c.setRelation(c.getRelation() == null ? Relation.OTHER : c.getRelation());
c.setCreatedAt(now);
c.setUpdateAt(now);
}
List<Contact> result = contactService.save(contactList);
List<XContact> xResult = convertObject(JSON.toJSONString(result), new TypeReference<List<XContact>>() {
});
if (!c.valid()) {
log.info("用户手机号或姓名错误, phoneNo:{},name:{}", c.getPhoneNo(), c.getName());
return returnErrorValue("用户手机号或姓名错误");
}
}
List<Contact> result = contactService.save(userId, contactList);
List<XContact> xResult = convertObject(JSON.toJSONString(result), new TypeReference<List<XContact>>(){});
return returnSuccessValue(xResult);
}
......@@ -388,7 +397,7 @@ public class MotanUserServiceImpl implements UserMotanService {
@Override
public UserSysResult<XAddress> saveAddress(Long userId, Long provinceCode, String province, Long cityCode, String city,
Long districtCode, String district, String address) {
if (null == userId || null == provinceCode || null == cityCode) {
if (null == userId || null == provinceCode || null == cityCode || StringUtils.isBlank(address)) {
return returnErrorValue("参数不能为空");
}
Address addressObj = addressService.findByUserId(userId);
......@@ -515,7 +524,7 @@ public class MotanUserServiceImpl implements UserMotanService {
return returnErrorValue("用户不能为空");
}
UserSpouse userSpouse = userSpouseService.findByUserId(userId);
if (userSpouse == null) {
if (userSpouse == null || !userSpouse.valid()) {
userSpouse = new UserSpouse(userId);
userSpouse.setStatus(MaritalStatus.UNKNOWN);
}
......@@ -594,8 +603,8 @@ public class MotanUserServiceImpl implements UserMotanService {
if (!ValidationUtil.validatePhoneNo(spousePhone)) {
return returnErrorValue("手机号格式错误");
}
if (StringUtils.isBlank(spouseName)) {
return returnErrorValue("配偶姓名不能为空");
if (!ValidationUtil.validateChinese(spouseName)) {
return returnErrorValue("配偶姓名错误");
}
}
UserSpouse userSpouse = userSpouseService.findByUserId(xUserSpouse.getUserId());
......@@ -805,7 +814,7 @@ public class MotanUserServiceImpl implements UserMotanService {
log.info("第三方(聚美)登录用户注册成功, registerFrom:{}, phoneNo:{},idNo:{},name:{} 并且已发送短信通知", registerFrom, phoneNo, idNo, name);
}
if (StringUtils.isNotEmpty(idNo) && StringUtils.isNotEmpty(name)) {
if (StringUtils.isNotBlank(idNo) && StringUtils.isNotBlank(name) && ValidationUtil.validateChinese(name)) {
IdCardInfo cardInfo;
try {
cardInfo = idCardService.getIdCardInfoWithExceptions(idNo);
......
......@@ -35,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.Objects;
import java.util.Random;
import static cn.quantgroup.xyqb.constant.UserConstant.USER_ERROR_OR_PASSWORD_ERROR;
......@@ -231,14 +233,10 @@ public class AppController implements IBaseController {
* @return
*/
private User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId) {
String randomCode = String.valueOf(random.nextInt(899999) + 100000);
String uuid = lkbUserService.registerApp(phoneNo, randomCode);
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
LOGGER.info("第三方登录用户,保存 User");
User user = new User();
if (channelId == 222L) {
user.setRegisteredFrom(channelId);
......@@ -262,7 +260,7 @@ public class AppController implements IBaseController {
LOGGER.info("第三方(聚美)登录用户注册成功, registerFrom:{}, phoneNo:{},idNo:{},name:{} 并且已发送短信通知", registerFrom, phoneNo, idNo, name);
}
if (StringUtils.isNotEmpty(idNo) && StringUtils.isNotEmpty(name)) {
if (StringUtils.isNotBlank(idNo) && StringUtils.isNotBlank(name) && ValidationUtil.validateChinese(name)) {
LOGGER.info("第三方登录用户,保存 UserDetail");
IdCardInfo cardInfo;
try {
......@@ -284,12 +282,7 @@ public class AppController implements IBaseController {
LOGGER.error("保存 UserDetail 出现异常", e);
}
}
//增加登陆统计发送
UserStatistics statistics=new UserStatistics(user,null,2,channelId);
MqUtils.sendLoanVest(statistics);
//增加用户注册广播
UserRegisterMqMessage registerMqMessage=new UserRegisterMqMessage(user);
MqUtils.sendRegisterMessage(registerMqMessage);
MqUtils.sendRegisterMessage(channelId,user);
return user;
}
......
......@@ -2,17 +2,25 @@ package cn.quantgroup.xyqb.controller.external.user;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.model.IdCardInfo;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.UserModel;
import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.IUserDetailService;
import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.Objects;
/**
* 同步用户数据,第三方模块访问时
* Created by Miraculous on 15/12/29.
......@@ -20,13 +28,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/sync")
public class SyncUserController {
private static final Logger LOGGER = LoggerFactory.getLogger(SyncUserController.class);
@Autowired
private IUserService userService;
@Autowired
private IUserDetailService userDetailService;
/*@Autowired
private IUserDetailRepository userDetailRepository;*/
@Autowired
private IIdCardService idCardService;
@Autowired
......@@ -56,9 +65,22 @@ public class SyncUserController {
@RequestMapping("/save_detail")
public JsonResult saveUserDetail(String key, UserDetail userDetail) {
if (StringUtils.isEmpty(key) || !"abc1234".equals(key)) {
if (StringUtils.isEmpty(key) || !"abc1234".equals(key) || Objects.isNull(userDetail) || StringUtils.isBlank(userDetail.getPhoneNo())) {
return JsonResult.buildErrorStateResult(null, null);
}
if (!ValidationUtil.validateChinese(userDetail.getName())) {
return JsonResult.buildErrorStateResult("姓名错误", null);
}
IdCardInfo info = null;
try {
info = idCardService.getIdCardInfo(userDetail.getIdNo());
} catch (ParseException ex) {
LOGGER.error("身份证号错误, idNo: {}", userDetail.getIdNo());
return JsonResult.buildErrorStateResult("身份证号码错误", null);
}
if (Objects.isNull(info) || !info.isValid()) {
return JsonResult.buildErrorStateResult("身份证号码错误", null);
}
String phoneNo = userDetail.getPhoneNo();
User user = userService.findByPhoneWithCache(phoneNo);
if (null == user) {
......
......@@ -11,6 +11,7 @@ import cn.quantgroup.xyqb.model.ContactRet;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.user.*;
import cn.quantgroup.user.enums.*;
import cn.quantgroup.xyqb.util.ValidationUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import org.apache.commons.collections.CollectionUtils;
......@@ -200,7 +201,7 @@ public class UserCenterController {
return JsonResult.buildErrorStateResult("该用户不存在", null);
}
UserExtInfo userExtInfo = userExtInfoService.findByUserId(userId);
List<Contact> contacts = contactService.findByUserId(userId);
List<Contact> contacts = contactService.findByUserId(userId, true);
Map<String, Object> result = new HashMap<>();
if(null != userExtInfo) {
result.put("contacts", null != contacts && contacts.size() > 0 ? true : false);
......@@ -244,32 +245,18 @@ public class UserCenterController {
LOGGER.error("保存联系人,联系人参数为空.contactJson:{}", contactJson);
return JsonResult.buildErrorStateResult(null, null);
}
List<Contact> userContact = contactService.findByUserId(userId);
/*if(userContact != null && userContact.size() >= 2) {
return JsonResult.buildSuccessResult(null, ContactRet.contacts2ContactRets(userContact));
}*/
//推翻之前逻辑,联系人可以更改.如果数据库已有记录.则更改
List<Contact> contacts = JSONObject.parseObject(contactJson, new TypeReference<List<Contact>>() {});
Timestamp now = new Timestamp(System.currentTimeMillis());
List<Contact> contacts = JSONObject.parseObject(contactJson, new TypeReference<List<Contact>>(){});
if (CollectionUtils.isEmpty(contacts)) {
return JsonResult.buildErrorStateResult("参数转换错误", null);
}
if(null != userContact && userContact.size() > 0) {
for(int i = 0; i < contacts.size(); i ++) {
contacts.get(i).setId(userContact.get(i).getId());
contacts.get(i).setUserId(userContact.get(i).getUserId());
contacts.get(i).setCreatedAt(now);
contacts.get(i).setUpdateAt(now);
}
} else {
for (Contact c : contacts) {
c.setId(null);
c.setUserId(userId);
c.setCreatedAt(now);
c.setUpdateAt(now);
LOGGER.info("联系人不能空");
return JsonResult.buildErrorStateResult(null, null);
}
for(Contact contact : contacts){
if (!contact.valid()) {
LOGGER.info("用户手机号或姓名错误, phoneNo:{},name:{}", contact.getPhoneNo(), contact.getName());
return JsonResult.buildErrorStateResult(null, null);
}
}
List<Contact> result = contactService.save(contacts);
List<Contact> result = contactService.save(userId, contacts);
return JsonResult.buildSuccessResult(null, result);
}
......@@ -285,8 +272,8 @@ public class UserCenterController {
@RequestMapping("/address/save")
public JsonResult saveUserAddress(String phoneNo, String province, Long provinceCode, String city, Long cityCode, String address,
Long districtCode, String district) {
LOGGER.info("保存用户地址信息, phoneNo:{}, province:{}, provinceCode:{}, city:{}, cityCode:{}", phoneNo, province, provinceCode, city, cityCode);
if (StringUtils.isEmpty(phoneNo) || provinceCode == null || cityCode == null) {
LOGGER.info("保存用户地址信息, phoneNo:{}, province:{}, provinceCode:{}, city:{}, cityCode:{},district:{}, address:{}", phoneNo, province, provinceCode, city, cityCode, district, address);
if (StringUtils.isEmpty(phoneNo) || provinceCode == null || cityCode == null || StringUtils.isBlank(address)) {
return JsonResult.buildErrorStateResult("参数错误", null);
}
Long userId = queryUserId(phoneNo);
......@@ -350,7 +337,7 @@ public class UserCenterController {
LOGGER.error("保存联系人,未获取到用户id. userId:{}", userId);
return JsonResult.buildErrorStateResult("该用户不存在", null);
}
List<Contact> contacts = contactService.findByUserId(userId);
List<Contact> contacts = contactService.findByUserId(userId, true);
return JsonResult.buildSuccessResult(null, contacts);
}
......
......@@ -162,11 +162,7 @@ public class UserController implements IBaseController {
}
User user=userService.registerAndReturn(phoneNo, password, registerFrom,btRegisterChannelId);
LOGGER.info("用户快速注册成功, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
UserStatistics statistics=new UserStatistics(user,dimension,2,channelId);
MqUtils.sendLoanVest(statistics);
//增加用户注册广播
UserRegisterMqMessage registerMqMessage=new UserRegisterMqMessage(user);
MqUtils.sendRegisterMessage(registerMqMessage);
MqUtils.sendRegisterMessage(channelId, user);
return user;
}
......
package cn.quantgroup.xyqb.entity;
import cn.quantgroup.user.enums.Relation;
import cn.quantgroup.xyqb.util.ValidationUtil;
import lombok.Data;
import javax.persistence.*;
......@@ -32,4 +33,13 @@ public class Contact implements Serializable {
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updateAt;
/**
* 数据合法性校验
* @return
*/
public boolean valid(){
return (ValidationUtil.validatePhoneNo(this.phoneNo) && ValidationUtil.validateChinese(this.name));
}
}
......@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.entity;
import cn.quantgroup.user.enums.MaritalStatus;
import cn.quantgroup.xyqb.util.ValidationUtil;
import lombok.*;
import javax.persistence.*;
......@@ -44,4 +45,12 @@ public class UserSpouse implements Serializable {
public UserSpouse(Long userId) {
this.userId = userId;
}
/**
* 数据合法性校验
* @return
*/
public boolean valid(){
return (ValidationUtil.validatePhoneNo(this.spousePhone) && ValidationUtil.validateChinese(this.spouseName));
}
}
......@@ -41,7 +41,7 @@ public class UserRet implements Serializable {
this.setId(user.getId());
this.setPhoneNo(user.getPhoneNo());
this.setEnable(user.getEnable());
this.setPassword(StringUtils.defaultIfEmpty(user.getPassword(), ""));
this.setPassword("");
this.setRegisteredFrom(user.getRegisteredFrom());
this.setUuid(user.getUuid());
this.setCreatedAt(createTimeStamp);
......
......@@ -55,7 +55,7 @@ public class PageServiceImpl implements IPageService {
private PageType pageContacts = new PageType("contacts", false) {
@Override
public boolean canPass(User user) {
List<Contact> contacts = contactService.findByUserId(user.getId());
List<Contact> contacts = contactService.findByUserId(user.getId(), true);
return contacts != null && contacts.size() != 0;
}
};
......
......@@ -9,11 +9,24 @@ import java.util.List;
* Created by Miraculous on 2017/1/3.
*/
public interface IContactService {
List<Contact> findByUserId(Long userId);
/**
*
* @param userId - 用户主键
* @param trim - 是否清除非法错误记录,true-清除,false-不清除
* @return
*/
List<Contact> findByUserId(Long userId, boolean trim);
Contact findById(Long id);
List<Contact> save(List<Contact> contacts);
/**
* 批量保存用户联系人
* 如果已存在联系人,则覆盖更新
* @param userId - 用户主键
* @param contacts - 联系人列表
* @return
*/
List<Contact> save(Long userId, List<Contact> contacts);
Contact save(Contact contact);
Contact saveContact(String name, String phoneNo, Relation relation, Contact contact);
......
......@@ -5,13 +5,21 @@ import cn.quantgroup.xyqb.controller.external.user.InnerController;
import cn.quantgroup.xyqb.entity.Contact;
import cn.quantgroup.xyqb.repository.IContactRepository;
import cn.quantgroup.xyqb.service.user.IContactService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.util.bcel.classfile.Constant;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
......@@ -24,9 +32,30 @@ public class ContactServiceImpl implements IContactService {
private IContactRepository contactRepository;
@Override
@Cacheable(value = "contact", key = "'contact' + #userId", unless = "#result == null or #result.size() == 0", cacheManager = "cacheManager")
public List<Contact> findByUserId(Long userId) {
return contactRepository.findByUserId(userId);
@Cacheable(value = "contact", key = "'contact:' + #trim + #userId", unless = "#result == null or #result.size() == 0", cacheManager = "cacheManager")
public List<Contact> findByUserId(Long userId, boolean trim) {
List<Contact> contacts = contactRepository.findByUserId(userId);
if(trim){
trim(contacts);
}
return contacts;
}
/**
* 过滤掉非法联系人记录
* @param contacts - 包含待清除记录的联系人列表
*/
private void trim(List<Contact> contacts){
if(CollectionUtils.isEmpty(contacts)){
return ;
}
Iterator<Contact> iterator = contacts.iterator();
while(iterator.hasNext()){
Contact contact = iterator.next();
if (!contact.valid()) {
iterator.remove();
}
}
}
@Override
......@@ -35,22 +64,32 @@ public class ContactServiceImpl implements IContactService {
}
@Override
@CacheEvict(value = "contact", key = "'contact' + #contacts.get(0).userId", cacheManager = "cacheManager")
public List<Contact> save(List<Contact> contacts) {
@Caching(evict = {
@CacheEvict(value = "contact", key = "'contact:true' + #userId", cacheManager = "cacheManager"),
@CacheEvict(value = "contact", key = "'contact:false' + #userId", cacheManager = "cacheManager")})
public List<Contact> save(Long userId, List<Contact> contacts) {
if(userId == null){
return null;
}
// 合并当前用户列表到更新列表
mergeContacts(userId, contacts);
return contactRepository.save(contacts);
}
@Override
@CacheEvict(value = "contact", key = "'contact' + #contact.userId", cacheManager = "cacheManager")
@Caching(evict = {
@CacheEvict(value = "contact", key = "'contact:true' + #contact.userId", cacheManager = "cacheManager"),
@CacheEvict(value = "contact", key = "'contact:false' + #contact.userId", cacheManager = "cacheManager")})
public Contact save(Contact contact) {
return contactRepository.save(contact);
}
@Override
public Contact saveContact(String name, String phoneNo, Relation relation, Contact contact) {
if (null != name) {
if (StringUtils.isNotBlank(name)) {
contact.setName(name);
}
if (null != phoneNo) {
if (StringUtils.isNotBlank(phoneNo)) {
contact.setPhoneNo(phoneNo);
}
if (null != relation) {
......@@ -62,4 +101,29 @@ public class ContactServiceImpl implements IContactService {
contact = save(contact);
return contact;
}
/**
* 合并当前用户列表到更新列表
* @param userId - 用户主键
* @param contacts - 新联系人列表
*/
private void mergeContacts(Long userId, List<Contact> contacts) {
// 当前联系人列表
List<Contact> userContact = contactRepository.findByUserId(userId);
int userContactCount = (userContact == null) ? 0 : userContact.size();
Timestamp now = new Timestamp(System.currentTimeMillis());
for(int i = 0; i < contacts.size(); i ++) {
Contact c = contacts.get(i);
c.setId(null);
c.setUserId(userId);
c.setRelation(c.getRelation() == null ? Relation.OTHER : c.getRelation());
c.setCreatedAt(now);
c.setUpdateAt(now);
if(userContactCount > i){
c.setId(userContact.get(i).getId());
c.setCreatedAt(contacts.get(i).getCreatedAt() == null ? now : contacts.get(i).getCreatedAt());
c.setRelation(contacts.get(i).getRelation() == null ? Relation.OTHER : contacts.get(i).getRelation());
}
}
}
}
......@@ -192,12 +192,7 @@ public class UserServiceImpl implements IUserService {
smsService.sendAfterRegister(phoneNo);
}
if(registerSuccess){
//增加登陆统计发送
UserStatistics statistics=new UserStatistics(user,dimension,2,channelId);
MqUtils.sendLoanVest(statistics);
//增加用户注册广播
UserRegisterMqMessage registerMqMessage=new UserRegisterMqMessage(user);
MqUtils.sendRegisterMessage(registerMqMessage);
MqUtils.sendRegisterMessage(channelId, user);
}
return user != null;
}
......
package cn.quantgroup.xyqb.util;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.UserRegisterMqMessage;
import cn.quantgroup.xyqb.model.UserRet;
import cn.quantgroup.xyqb.model.UserStatistics;
import cn.quantgroup.xyqb.service.mq.IRegisterMqService;
import cn.quantgroup.xyqb.service.mq.IVestService;
......@@ -37,4 +39,15 @@ public class MqUtils {
message, e);
}
}
public static UserRet sendRegisterMessage(Long registeredFrom, User user) {
UserRet userRet;
UserStatistics statistics=new UserStatistics(user,null,2,registeredFrom);
MqUtils.sendLoanVest(statistics);
userRet = new UserRet(user);
//增加用户注册广播
UserRegisterMqMessage registerMqMessage=new UserRegisterMqMessage(user);
MqUtils.sendRegisterMessage(registerMqMessage);
return userRet;
}
}
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