controller_adjust
Change-Id: I1929a8c33006ca473d1ca4aa451e3bedf74c0c8a
diff --git a/src/main/java/com/example/g8backend/controller/UserSecurityController.java b/src/main/java/com/example/g8backend/controller/UserSecurityController.java
index 34bbb96..0f41549 100644
--- a/src/main/java/com/example/g8backend/controller/UserSecurityController.java
+++ b/src/main/java/com/example/g8backend/controller/UserSecurityController.java
@@ -1,9 +1,9 @@
package com.example.g8backend.controller;
import com.example.g8backend.dto.PasswordChangeDTO;
+import com.example.g8backend.dto.ApiResponse;
import com.example.g8backend.service.IUserSecurityService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
@@ -11,14 +11,19 @@
@RestController
@RequestMapping("/user/security")
public class UserSecurityController {
+
@Autowired
private IUserSecurityService userSecurityService;
@PutMapping("/change-password")
- public ResponseEntity<?> changePassword(@RequestBody PasswordChangeDTO dto) {
+ public ApiResponse<String> changePassword(@RequestBody PasswordChangeDTO dto) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Long userId = (Long) authentication.getPrincipal();
+
+ // 调用服务层进行密码修改
userSecurityService.changePassword(userId, dto.getOldPassword(), dto.getNewPassword());
- return ResponseEntity.ok("密码修改成功");
+
+ // 返回统一的成功响应
+ return ApiResponse.success("密码修改成功");
}
-}
\ No newline at end of file
+}