From 7c07ae9421850650b9da6d453c498cc3049a83a3 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 26 十二月 2023 15:03:00 +0800
Subject: [PATCH] 修复文档页面不可用BUG,支持设置认证消息头来方便调用其他接口

---
 src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
old mode 100644
new mode 100755
index d23b03c..a2aefb1
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
@@ -14,6 +14,7 @@
 import com.github.pagehelper.PageInfo;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.AuthenticationManager;
@@ -57,7 +58,7 @@
         if (user == null) {
             throw new ControllerException(ErrorCode.ERROR100.getCode(), "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒");
         }else {
-            String jwt = JwtUtils.createToken(username, password);
+            String jwt = JwtUtils.createToken(username);
             response.setHeader(JwtUtils.getHeader(), jwt);
             user.setAccessToken(jwt);
         }
@@ -83,8 +84,8 @@
             if (user == null) {
                 throw new ControllerException(ErrorCode.ERROR100);
             }
-            int userId = SecurityUtils.getUserId();
-            boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes()));
+            //int userId = SecurityUtils.getUserId();
+            boolean result = userService.changePassword(user.getId(), DigestUtils.md5DigestAsHex(password.getBytes()));
             if (!result) {
                 throw new ControllerException(ErrorCode.ERROR100);
             }
@@ -95,7 +96,7 @@
 
 
     @PostMapping("/add")
-    @Operation(summary = "娣诲姞鐢ㄦ埛")
+    @Operation(summary = "娣诲姞鐢ㄦ埛", security = @SecurityRequirement(name = JwtUtils.HEADER))
     @Parameter(name = "username", description = "鐢ㄦ埛鍚�", required = true)
     @Parameter(name = "password", description = "瀵嗙爜锛堟湭md5鍔犲瘑鐨勫瘑鐮侊級", required = true)
     @Parameter(name = "roleId", description = "瑙掕壊ID", required = true)

--
Gitblit v1.8.0