From 259b1d62921acfb9ced17ff55baf2b7c73ddfe02 Mon Sep 17 00:00:00 2001 From: hanpaopao <510423039@qq.com> Date: Wed, 20 Nov 2024 15:07:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E6=9F=A5=E6=89=BE=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Users/Dtos/FindByUserNameInput.cs | 6 ++++++ .../Users/IUserAppService.cs | 9 +++++++-- .../Users/UserAppService.cs | 13 +++++++++++++ .../BasicManagementErrorCodes.cs | 1 + .../Localization/BasicManagement/en.json | 3 ++- .../Localization/BasicManagement/zh-Hans.json | 3 ++- .../Systems/UserController.cs | 7 +++++++ 7 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/FindByUserNameInput.cs diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/FindByUserNameInput.cs b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/FindByUserNameInput.cs new file mode 100644 index 00000000..6f675fc0 --- /dev/null +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/FindByUserNameInput.cs @@ -0,0 +1,6 @@ +namespace Lion.AbpPro.BasicManagement.Users.Dtos; + +public class FindByUserNameInput +{ + public string UserName { get; set; } +} \ No newline at end of file diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs index f342b620..549ca61c 100644 --- a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs @@ -16,12 +16,12 @@ namespace Lion.AbpPro.BasicManagement.Users /// 分页查询用户 /// Task> ListAllAsync(PagingUserListInput input); - + /// /// 用户导出列表 /// Task ExportAsync(PagingUserListInput input); - + /// /// 新增用户 /// @@ -52,5 +52,10 @@ namespace Lion.AbpPro.BasicManagement.Users /// 锁定用户 /// Task LockAsync(LockUserInput input); + + /// + /// 通过username获取用户信息 + /// + Task FindByUserNameAsync(FindByUserNameInput input); } } \ No newline at end of file diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs index 35097822..7634967e 100644 --- a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs @@ -167,5 +167,18 @@ namespace Lion.AbpPro.BasicManagement.Users identityUser.SetIsActive(input.Locked); await _userManager.UpdateAsync(identityUser); } + + /// + /// 通过username获取用户信息 + /// + public virtual async Task FindByUserNameAsync(FindByUserNameInput input) + { + var user = await _userManager.FindByNameAsync(input.UserName); + if (user == null) + { + throw new BusinessException(BasicManagementErrorCodes.UserNotExist); + } + return ObjectMapper.Map(user); + } } } \ No newline at end of file diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/BasicManagementErrorCodes.cs b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/BasicManagementErrorCodes.cs index 71ab948a..6061fcf1 100644 --- a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/BasicManagementErrorCodes.cs +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/BasicManagementErrorCodes.cs @@ -8,4 +8,5 @@ public static class BasicManagementErrorCodes public const string UserDisabled = BasicManagementConsts.NameSpace + ":100004"; public const string TenantNotExist = BasicManagementConsts.NameSpace + ":100005"; public const string NotSupportSetConnectionString = BasicManagementConsts.NameSpace + ":100006"; + public const string UserNotExist = BasicManagementConsts.NameSpace + ":100007"; } \ No newline at end of file diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/en.json b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/en.json index 079005f3..16b5ccb2 100644 --- a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/en.json +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/en.json @@ -22,6 +22,7 @@ "Lion.AbpPro.BasicManagement:100003": "UserOrPasswordMismatch", "Lion.AbpPro.BasicManagement:100004": "UserDisabled", "Lion.AbpPro.BasicManagement:100005": "Tenant Not Exist", - "Lion.AbpPro.BasicManagement:100006": "Not Support Set ConnectionString" + "Lion.AbpPro.BasicManagement:100006": "Not Support Set ConnectionString", + "Lion.AbpPro.BasicManagement:100007": "User Not Exist" } } \ No newline at end of file diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/zh-Hans.json b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/zh-Hans.json index 2a0a3fea..91d5bc6b 100644 --- a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/zh-Hans.json +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/zh-Hans.json @@ -22,6 +22,7 @@ "Lion.AbpPro.BasicManagement:100003": "用户名或者密码错误", "Lion.AbpPro.BasicManagement:100004": "用户已禁用", "Lion.AbpPro.BasicManagement:100005": "租户不存在", - "Lion.AbpPro.BasicManagement:100006": "当前模块不支持设置数据库连接字符串" + "Lion.AbpPro.BasicManagement:100006": "当前模块不支持设置数据库连接字符串", + "Lion.AbpPro.BasicManagement:100007": "用户不存在" } } \ No newline at end of file diff --git a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs index e124f839..25b29255 100644 --- a/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs +++ b/aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs @@ -77,5 +77,12 @@ namespace Lion.AbpPro.BasicManagement.Systems { return _userAppService.LockAsync(input); } + + [HttpPost("findByUserName")] + [SwaggerOperation(summary: "通过用户名查找用户", Tags = new[] { "Users" })] + public Task FindByUserNameAsync(FindByUserNameInput input) + { + return _userAppService.FindByUserNameAsync(input); + } } } \ No newline at end of file