更新了写真预约特殊产品处理

This commit is contained in:
chen-xin-zhi 2025-03-12 19:56:36 +08:00
parent 06bdf661d9
commit add07d4931
2 changed files with 13 additions and 4 deletions
src/main/java/com/cultural/heritage
controller/user
service/user/impl

View File

@ -231,8 +231,14 @@ public class UserController {
}
User user = new User();
BeanUtils.copyProperties(userUpdateRequest, user);
String encryptPassword = DigestUtils.md5DigestAsHex((SALT + user.getUserPassword()).getBytes());
user.setUserPassword(encryptPassword);
Long id = user.getId();
User sourceUser = userService.getById(id);
String userPassword = user.getUserPassword();
if (!sourceUser.getUserPassword().equals(userPassword)) {
String newPassword = DigestUtils.md5DigestAsHex((SALT + userPassword).getBytes());
user.setUserPassword(newPassword);
}
userService.validUser(user, true);
boolean result = userService.updateById(user);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
@ -240,6 +246,9 @@ public class UserController {
}
/**
* 根据 id 获取用户
* @param id

View File

@ -83,14 +83,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
public void validUser(User user, boolean update) {
String userPassword = user.getUserPassword();
String userName = user.getUserName();
String userPassword = user.getUserPassword();
String userAvatar = user.getUserAvatar();
String phone = user.getPhone();
String userRole = user.getUserRole();
Long id = user.getId();
ThrowUtils.throwIf(update && id == null, ErrorCode.OPERATION_ERROR, "id字段为null");
if (StringUtils.isAnyBlank(userPassword, userName, userAvatar, phone, userRole)) {
if (StringUtils.isAnyBlank(userName, userAvatar, phone, userRole, userPassword)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "存在参数为空");
}
ThrowUtils.throwIf(RegexUtils.isPhoneInvalid(phone), ErrorCode.OPERATION_ERROR, "手机号格式错误");