v0.1.6 完善注释,优化异常,完成用户模块RESTful接口设置
parent
0ca2a5317b
commit
f2a45f123b
|
|
@ -20,7 +20,7 @@ public class UserController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量导入用户
|
* 批量导入用户
|
||||||
*
|
* todo 准备引入Excel导入机制
|
||||||
* @param users 用户列表
|
* @param users 用户列表
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue