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

debug:/api/sync/save_detail未判断是否已存在,直接save存在问题,改为先预判,再执行save(新增或更新)

parent 5163603a
...@@ -83,11 +83,23 @@ public class SyncUserController { ...@@ -83,11 +83,23 @@ public class SyncUserController {
} }
String phoneNo = userDetail.getPhoneNo(); String phoneNo = userDetail.getPhoneNo();
User user = userService.findByPhoneWithCache(phoneNo); User user = userService.findByPhoneWithCache(phoneNo);
if (null == user) { if(Objects.isNull(user)){
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
userDetail.setId(null); userDetail.setId(null);
userDetail.setUserId(user.getId()); userDetail.setUserId(user.getId());
/*
* 如果已存在记录,则更新
*/
UserDetail theUserDetail = userDetailService.findByPhoneNo(phoneNo);
if(Objects.isNull(theUserDetail)){
theUserDetail = userDetailService.findByUserId(user.getId());
}
if(Objects.isNull(theUserDetail)){
userDetail.setId(null);
}else {
userDetail.setId(theUserDetail.getId());
}
userDetailService.saveUserDetail(userDetail); userDetailService.saveUserDetail(userDetail);
return JsonResult.buildSuccessResult(null, null); return JsonResult.buildSuccessResult(null, 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