v0.1.6 完善注释,优化异常,完成用户模块RESTful接口设置

v0.1
bruce 2025-02-14 12:28:10 +08:00
parent 0ca2a5317b
commit f2a45f123b
4 changed files with 17 additions and 5 deletions

View File

@ -20,7 +20,7 @@ public class UserController {
/** /**
* *
* * todo Excel
* @param users * @param users
* @return * @return
*/ */

View File

@ -18,6 +18,10 @@ public class UserProfileController {
/** /**
* *
*
* @param userId
* @param oldPassword
* @param newPassword
*/ */
@PutMapping("/change-password") @PutMapping("/change-password")
public AjaxResult changePassword(@RequestAttribute Long userId, public AjaxResult changePassword(@RequestAttribute Long userId,
@ -29,6 +33,10 @@ public class UserProfileController {
/** /**
* *
*
* @param userId
* @param user
* @return
*/ */
@PutMapping("/update") @PutMapping("/update")
public AjaxResult updateProfile(@RequestAttribute Long userId, @RequestBody User user) { public AjaxResult updateProfile(@RequestAttribute Long userId, @RequestBody User user) {

View File

@ -9,4 +9,8 @@ public class PasswordIncorrectException extends CustomException {
public PasswordIncorrectException() { public PasswordIncorrectException() {
super(HttpStatus.UNAUTHORIZED, "账号或密码错误"); super(HttpStatus.UNAUTHORIZED, "账号或密码错误");
} }
public PasswordIncorrectException(String message) {
super(HttpStatus.UNAUTHORIZED, message);
}
} }

View File

@ -83,7 +83,7 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, User>
// 验证旧密码 // 验证旧密码
if (!PasswordUtil.matches(oldPassword, user.getPassword())) { if (!PasswordUtil.matches(oldPassword, user.getPassword())) {
throw new PasswordIncorrectException(); throw new PasswordIncorrectException("原密码错误");
} }
// 更新新密码(加密存储) // 更新新密码(加密存储)
@ -92,10 +92,10 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, User>
} }
/** /**
* *
* *
* @param userId ID JWT * @param userId ID
* @param updatedUser * @param updatedUser
*/ */
public void updateProfile(Long userId, User updatedUser) { public void updateProfile(Long userId, User updatedUser) {
User user = userMapper.selectById(userId); User user = userMapper.selectById(userId);