Commit 9e90a618 authored by xiaoguang.xu's avatar xiaoguang.xu

fix : userHashMapping 重复保存不报错

parent e8845f0e
......@@ -6,11 +6,12 @@ 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.hibernate.exception.ConstraintViolationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import javax.persistence.PersistenceException;
@Component
@Slf4j
public class PhoneHashEventListener implements ApplicationListener<RegisterEvent> {
......@@ -45,7 +46,7 @@ public class PhoneHashEventListener implements ApplicationListener<RegisterEvent
try {
userHashMappingRepository.saveAndFlush(userHashMapping);
} catch (ConstraintViolationException e) {
} catch (PersistenceException e) {
log.error("保存userHashMapping重复, 无需再保存, userId:{}", userId);
}
......
......@@ -6,11 +6,12 @@ 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.hibernate.exception.ConstraintViolationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import javax.persistence.PersistenceException;
/**
* userDetail 更新时, 保存 hashMapping 数据
......@@ -50,7 +51,7 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta
userHashMapping.setIdNoMd5(idNoMd5New);
try {
userHashMappingRepository.save(userHashMapping);
} catch (ConstraintViolationException e) {
} catch (PersistenceException e){
log.error("保存userHashMapping重复, 无需再保存, userId:{}", userDetail.getUserId());
}
......
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