Commit 00d4cc8f authored by 技术部-任文超's avatar 技术部-任文超

代码容错

parent f05a82ba
......@@ -295,11 +295,15 @@ public class InnerController implements IBaseController {
@LogHttpCaller
@RequestMapping("/user_detail/search/userId")
public JsonResult findUserDetailByUserId(Long userId) {
UserDetail userDetail = userDetailService.findByUserId(userId);
if (userDetail != null) {
return JsonResult.buildSuccessResult(null, UserDetailRet.getUserDetail(userDetail));
UserDetail userDetail = null;
// 增加容错性,防备DB中存在的脏数据触发异常
if(userId != null && userId > 0){
userDetail = userDetailService.findByUserId(userId);
}
return JsonResult.buildErrorStateResult("", null);
if(Objects.isNull(userDetail)) {
return JsonResult.buildErrorStateResult("", null);
}
return JsonResult.buildSuccessResult(null, UserDetailRet.getUserDetail(userDetail));
}
@LogHttpCaller
......
......@@ -181,13 +181,17 @@ public class UserController implements IBaseController {
JsonResult successResult = validMap.get("success");
String phoneNo = successResult.getData().toString();
if (!ValidationUtil.validatePhoneNo(phoneNo)) {
LOGGER.info("用户快速注册失败,手机号错误, createdFrom:{},phoneNo:{}", createdFrom, phoneNo);
LOGGER.info("用户快速登录失败,手机号错误, createdFrom:{},phoneNo:{}", createdFrom, phoneNo);
throw new UserNotExistException("手机号错误");
}
String verificationCode = successResult.getMsg();
// 执行短信验证码检查
verifyPhoneAndCode(phoneNo, verificationCode);
User user = userService.findByPhoneWithCache(phoneNo);
// 缓存未命中时查DB
if (user == null) {
user = userService.findByPhoneInDb(phoneNo);
}
if (user != null && !user.getEnable()) {
LOGGER.error("用户不存在,或者已经注销,phoneNo:{}",phoneNo);
return JsonResult.buildErrorStateResult("登录失败", null);
......
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