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