网站用户个人信息更新问题

This commit is contained in:
wanggeng 2022-11-28 09:52:01 +08:00
parent 1f5b67b4f5
commit fe923f1987
4 changed files with 20 additions and 29 deletions

View File

@ -43,7 +43,7 @@ public class UserExpandController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-byuserid/{userId}") @PutMapping("update-byuserid/{userId}")
@CheckRequestBodyAnnotation @CheckRequestBodyAnnotation
public SuccessResult update(@PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) { public SuccessResult update(@PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) throws Exception {
userExpandService.updateByUserId(null, userId, userExpandVO); userExpandService.updateByUserId(null, userId, userExpandVO);
return new SuccessResult(); return new SuccessResult();
} }

View File

@ -44,7 +44,7 @@ public class UserExpandAppController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-byuserid/{userId}") @PutMapping("update-byuserid/{userId}")
@CheckRequestBodyAnnotation @CheckRequestBodyAnnotation
public SuccessResult updateUserExpand(@RequestHeader("token") String token, @PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) { public SuccessResult updateUserExpand(@RequestHeader("token") String token, @PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) throws Exception {
userExpandService.updateByUserId(token, userId, userExpandVO); userExpandService.updateByUserId(token, userId, userExpandVO);
return new SuccessResult(); return new SuccessResult();
} }

View File

@ -35,7 +35,7 @@ public interface IUserExpandService extends IUserExpandBaseService<UserExpandDTO
* @param userId * @param userId
* @param userExpandVO * @param userExpandVO
*/ */
void updateByUserId(String token, String userId, UserExpandVO userExpandVO); void updateByUserId(String token, String userId, UserExpandVO userExpandVO) throws Exception;
/** /**

View File

@ -53,13 +53,13 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
@Override @Override
public UserExpandDTO getByUserId(String userId) { public UserExpandDTO getByUserId(String userId) {
UserDTO userDTO = userService.get(userId); UserDTO userDTO = userService.get(userId);
if(userDTO == null){ if (userDTO == null) {
throw new SearchException("用户不存在"); throw new SearchException("用户不存在");
} }
Map<String,Object> params = super.getHashMap(3); Map<String, Object> params = super.getHashMap(3);
params.put("userId",userId); params.put("userId", userId);
UserExpandDTO userExpandDTO = this.get(params); UserExpandDTO userExpandDTO = this.get(params);
if(userExpandDTO == null){ if (userExpandDTO == null) {
userExpandDTO = new UserExpandDTO(); userExpandDTO = new UserExpandDTO();
} }
userExpandDTO.setUserName(userDTO.getUserName()); userExpandDTO.setUserName(userDTO.getUserName());
@ -69,32 +69,28 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
} }
public void updateByUserId(String token, String userId, UserExpandVO userExpandVO){ public void updateByUserId(String token, String userId, UserExpandVO userExpandVO) throws Exception {
Map<String,Object> params = super.getHashMap(1); Map<String, Object> params = super.getHashMap(1);
params.put("userId", userId); params.put("userId", userId);
UserExpandDTO userExpandDTO = this.get(params); UserExpandDTO userExpandDTO = this.get(params);
// 1.保存拓展信息 // 1.保存拓展信息
if(userExpandDTO == null){ if (userExpandDTO == null) {
this.saveReturnId(token, userId, userExpandVO); this.saveReturnId(token, userId, userExpandVO);
}else{ } else {
this.update(token,userExpandDTO.getUserExpandId(),userExpandVO); this.update(token, userExpandDTO.getUserExpandId(), userExpandVO);
}
if (StringUtils.isBlank(token)) {
return;
} }
// 2.更新用户信息 // 2.更新用户信息
UpdateUserVO updateUserVO = new UpdateUserVO(); UpdateUserVO updateUserVO = new UpdateUserVO();
try { updateUserVO.setName(userExpandVO.getName());
updateUserVO.setName(userExpandVO.getName()); updateUserVO.setPhone(userExpandVO.getPhone());
updateUserVO.setPhone(userExpandVO.getPhone()); updateUserVO.setEmail(userExpandVO.getEmail());
updateUserVO.setEmail(userExpandVO.getEmail()); userService.updateInfo(token, updateUserVO);
userService.updateInfo(token,updateUserVO);
} catch (Exception e) {
throw new UpdateException("更新用户信息失败");
}
} }
@Override @Override
public UserExpandDTO getByUsername(String username) { public UserExpandDTO getByUsername(String username) {
return null; return null;
@ -137,11 +133,6 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
} }
@Override @Override
public void save(UserExpandVO userExpandVO) { public void save(UserExpandVO userExpandVO) {
saveReturnId(userExpandVO); saveReturnId(userExpandVO);
@ -156,6 +147,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
public String saveReturnId(UserExpandVO userExpandVO) { public String saveReturnId(UserExpandVO userExpandVO) {
return saveReturnId(null, userExpandVO); return saveReturnId(null, userExpandVO);
} }
@Override @Override
public String saveReturnId(String token, UserExpandVO userExpandVO) { public String saveReturnId(String token, UserExpandVO userExpandVO) {
String userExpandId = UUIDUtil.getUUID(); String userExpandId = UUIDUtil.getUUID();
@ -287,7 +279,6 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
} }
@Override @Override
public Integer count(Map<String, Object> params) { public Integer count(Map<String, Object> params) {
Integer count = userExpandDao.count(params); Integer count = userExpandDao.count(params);