Commit 96350fb2 authored by 技术部-任文超's avatar 技术部-任文超

解决线上写实名账户时经常触发idNo唯一约束异常的问题

parent 65b7ba06
......@@ -9,11 +9,13 @@ import cn.quantgroup.xyqb.service.auth.IUserAuthorizedService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.Objects;
/**
* @author xufei on 2018/1/5.
......@@ -27,6 +29,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Resource
private IUserAuthorizedRepository userAuthorizedRepository;
@Cacheable(value = "user_authorized_idno_cache", key = "#idNo", unless = "#result == null", cacheManager = "cacheManager")
@Override
public Boolean hasUserAuthorized(String idNo) {
try {
......@@ -35,6 +38,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
}
} catch (ParseException e) {
LOGGER.error("[hasUserAuthorized]参数异常e:{}", e);
return Boolean.FALSE;
}
UserAuthorized userAuthorized = userAuthorizedRepository.findByIdNo(idNo);
......@@ -62,6 +66,10 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Override
public UserAuthorized createUserAuthorized(UserAuthorizedParam userAuthorizedParam) {
// 数据检查
if(Objects.isNull(userAuthorizedParam) || this.hasUserAuthorized(userAuthorizedParam.getIdNo())){
return null;
}
AuthPattern authPatternEnum = AuthPattern.valueOf(userAuthorizedParam.getAuthPattern());
UserAuthorized userAuthorized = new UserAuthorized();
......@@ -84,6 +92,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
}
}
@Cacheable(value = "user_authorized_uuid_2_id_cache", key = "#userUuid", unless = "#result == null", cacheManager = "cacheManager")
@Override
public String getUserAuthorizedId(String userUuid) {
if (StringUtils.isBlank(userUuid)) {
......
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