Commit 0c29b91b authored by xiaoguang.xu's avatar xiaoguang.xu

fix : 修复某种条件下 user hash mapping 数据比user detail 创建晚的情况

parent 28ccf13c
......@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.entity.UserHashMapping;
import cn.quantgroup.xyqb.repository.IUserHashMappingRepository;
import cn.quantgroup.xyqb.util.encrypt.MD5Util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
......@@ -13,6 +14,7 @@ import org.springframework.stereotype.Component;
* userDetail 更新时, 保存 hashMapping 数据
*/
@Component
@Slf4j
public class UserDetailHashEventListener implements ApplicationListener<UserDetailUpdateEvent> {
@Autowired
......@@ -25,6 +27,13 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta
UserHashMapping userHashMapping = userHashMappingRepository.findByUserId(userDetail.getUserId());
//如果不存在, 我先保存一下
if (userHashMapping == null) {
userHashMapping = new UserHashMapping(userDetail.getUserId());
String phoneNo = userDetail.getPhoneNo();
userHashMapping.setPhoneNoMd5(MD5Util.build(phoneNo));
}
String idNoMd5 = userHashMapping.getIdNoMd5();
String idNo = userDetail.getIdNo().toUpperCase();
......
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