Browse Source

feat: 添加获取个人信息接口

fix-permisson
Hanpaopao 1 year ago
parent
commit
1e09358b29
  1. 20
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/MyProfileOutput.cs
  2. 5
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/IUserAppService.cs
  3. 1
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/BasicManagementApplicationAutoMapperProfile.cs
  4. 10
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs
  5. 7
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs

20
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Users/Dtos/MyProfileOutput.cs

@ -0,0 +1,20 @@
namespace Lion.AbpPro.BasicManagement.Users.Dtos;
public class MyProfileOutput
{
public Guid? TenantId { get; set; }
public string UserName { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public bool IsActive { get; set; }
public bool TwoFactorEnabled { get; set; }
}

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

@ -57,5 +57,10 @@ namespace Lion.AbpPro.BasicManagement.Users
/// 通过username获取用户信息
/// </summary>
Task<IdentityUserDto> FindByUserNameAsync(FindByUserNameInput input);
/// <summary>
/// 获取个人信息
/// </summary>
Task<MyProfileOutput> MyProfileAsync();
}
}

1
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/BasicManagementApplicationAutoMapperProfile.cs

@ -35,5 +35,6 @@ public class BasicManagementApplicationAutoMapperProfile : Profile
CreateMap<IdentityRole, GetUnAddRoleOutput>();
CreateMap<IdentitySecurityLog, PagingIdentitySecurityLogOutput>();
CreateMap<TenantConnectionString, PageTenantConnectionStringOutput>();
CreateMap<IdentityUser, MyProfileOutput>();
}
}

10
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Users/UserAppService.cs

@ -179,5 +179,15 @@ namespace Lion.AbpPro.BasicManagement.Users
}
return ObjectMapper.Map<Volo.Abp.Identity.IdentityUser, IdentityUserDto>(user);
}
public virtual async Task<MyProfileOutput> MyProfileAsync()
{
var user = await _userManager.FindByIdAsync(CurrentUser.GetId().ToString());
if (user == null)
{
throw new BusinessException(BasicManagementErrorCodes.UserNotExist);
}
return ObjectMapper.Map<Volo.Abp.Identity.IdentityUser, MyProfileOutput>(user);
}
}
}

7
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.HttpApi/Systems/UserController.cs

@ -84,5 +84,12 @@ namespace Lion.AbpPro.BasicManagement.Systems
{
return _userAppService.FindByUserNameAsync(input);
}
[HttpPost("myProfile")]
[SwaggerOperation(summary: "获取个人信息", Tags = new[] { "Users" })]
public Task<MyProfileOutput> MyProfileAsync()
{
return _userAppService.MyProfileAsync();
}
}
}
Loading…
Cancel
Save