From 062c5f94776995ca21ce5905b09ab6c856033fd8 Mon Sep 17 00:00:00 2001 From: luolan Date: Thu, 10 Jul 2025 23:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=E4=B8=AD=E7=9A=84JWT=E5=A3=B0=E6=98=8E?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=8C=E5=B9=B6=E5=9C=A8=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B5=84=E6=96=99=E4=B8=AD=E6=B7=BB=E5=8A=A0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGSS/Controllers/User/UserControllers.cs | 13 ++++++------- AGSS/Models/DTOs/UserProfile.cs | 2 ++ AGSS/Services/UserService.cs | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/AGSS/Controllers/User/UserControllers.cs b/AGSS/Controllers/User/UserControllers.cs index 3e0891d..8e16b8e 100644 --- a/AGSS/Controllers/User/UserControllers.cs +++ b/AGSS/Controllers/User/UserControllers.cs @@ -39,21 +39,20 @@ public class UserControllers:ControllerBase [HttpGet] public async Task My() { - string userId = this.User.FindFirst(JwtRegisteredClaimNames.Sub)!.Value; - if (string.IsNullOrEmpty(userId)) - { - return Ok(new ReturnTemplate(500,"获取用户失败(JWT解析错误)",null)); - } + + + + + string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value; try { var userProfile = await _userService.GetUserProfileAsync(userId); - return Ok(new ReturnTemplate(200,"获取成功!",userProfile)); + return Ok(new ReturnTemplate(200, "获取成功!", userProfile)); } catch (ArgumentException ex) { return NotFound(ex.Message); } - } } \ No newline at end of file diff --git a/AGSS/Models/DTOs/UserProfile.cs b/AGSS/Models/DTOs/UserProfile.cs index 063ab64..4c47f59 100644 --- a/AGSS/Models/DTOs/UserProfile.cs +++ b/AGSS/Models/DTOs/UserProfile.cs @@ -11,4 +11,6 @@ public class UserProfile public string? JobCode { get; set; } public string? JobName { get; set; } public string? Birthday { get; set; } + public string? MenuCode { get; set; } + public string? MenuName { get; set; } } diff --git a/AGSS/Services/UserService.cs b/AGSS/Services/UserService.cs index f688a12..343c590 100644 --- a/AGSS/Services/UserService.cs +++ b/AGSS/Services/UserService.cs @@ -29,7 +29,9 @@ public class UserService Config = user.Config, JobCode = user.JobCode, JobName = user.JobName, - Birthday = user.Birthday + Birthday = user.Birthday, + MenuCode = user.MenuCode, + MenuName = user.MenuName }; } }