Browse Source

feat: 添加通过用户名查找用户接口

production
hanpaopao 1 year ago
parent
commit
259b1d6292
  1. 6
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/FindByUserNameInput.cs
  2. 5
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs
  3. 13
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs
  4. 1
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/BasicManagementErrorCodes.cs
  5. 3
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/en.json
  6. 3
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Domain.Shared/Localization/BasicManagement/zh-Hans.json
  7. 7
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs

6
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; }
}

5
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs

@ -52,5 +52,10 @@ namespace Lion.AbpPro.BasicManagement.Users
/// 锁定用户
/// </summary>
Task LockAsync(LockUserInput input);
/// <summary>
/// 通过username获取用户信息
/// </summary>
Task<IdentityUserDto> FindByUserNameAsync(FindByUserNameInput input);
}
}

13
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);
}
/// <summary>
/// 通过username获取用户信息
/// </summary>
public virtual async Task<IdentityUserDto> FindByUserNameAsync(FindByUserNameInput input)
{
var user = await _userManager.FindByNameAsync(input.UserName);
if (user == null)
{
throw new BusinessException(BasicManagementErrorCodes.UserNotExist);
}
return ObjectMapper.Map<Volo.Abp.Identity.IdentityUser, IdentityUserDto>(user);
}
}
}

1
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";
}

3
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"
}
}

3
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": "用户不存在"
}
}

7
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<IdentityUserDto> FindByUserNameAsync(FindByUserNameInput input)
{
return _userAppService.FindByUserNameAsync(input);
}
}
}
Loading…
Cancel
Save