云文件管理系统上传组件优化
This commit is contained in:
@@ -122,4 +122,26 @@ public class UserController {
|
||||
userService.updateProfile(principal.getUserId(), nickname, signature, phone, email);
|
||||
return ResponseEntity.ok(Map.of("message", "更新成功"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@PutMapping("/password")
|
||||
public ResponseEntity<?> changePassword(
|
||||
@AuthenticationPrincipal UserPrincipal principal,
|
||||
@RequestBody Map<String, String> request) {
|
||||
String oldPassword = request.get("oldPassword");
|
||||
String newPassword = request.get("newPassword");
|
||||
|
||||
if (oldPassword == null || oldPassword.isEmpty() || newPassword == null || newPassword.isEmpty()) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "请填写完整信息"));
|
||||
}
|
||||
|
||||
try {
|
||||
userService.changePassword(principal.getUserId(), oldPassword, newPassword);
|
||||
return ResponseEntity.ok(Map.of("message", "密码修改成功"));
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user