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

代码容错

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