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

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)})
@PutMapping("update-byuserid/{userId}")
@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);
return new SuccessResult();
}

View File

@ -44,7 +44,7 @@ public class UserExpandAppController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-byuserid/{userId}")
@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);
return new SuccessResult();
}

View File

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