Browse Source

新增 用户 部门获取

dev_DY_CC
郑勃旭 11 months ago
parent
commit
fe3803b4f8
  1. 1
      be/Hosts/Auth.Host/src/Win_in.Sfs.Auth.Application.Contracts/Departments/IDepartmentAppService.cs
  2. 21
      be/Hosts/Auth.Host/src/Win_in.Sfs.Auth.Application/Departments/DepartmentAppService.cs

1
be/Hosts/Auth.Host/src/Win_in.Sfs.Auth.Application.Contracts/Departments/IDepartmentAppService.cs

@ -9,4 +9,5 @@ public interface IDepartmentAppService
{
Task<DepartmentDTO> GetByUsernameAsync(string username);
Task UpdateAsync(DepartmentCreateInput input);
Task<DepartmentDTO> GetByUserIdAsync(string userId);
}

21
be/Hosts/Auth.Host/src/Win_in.Sfs.Auth.Application/Departments/DepartmentAppService.cs

@ -49,6 +49,27 @@ public class DepartmentAppService
var deptDto = await GetByCodeAsync(departmentCode).ConfigureAwait(false);
return deptDto;
}
[AllowAnonymous]
[HttpGet("by-userid")]
public virtual async Task<DepartmentDTO> GetByUserIdAsync(string userId)
{
var user = await _identityUserManager.FindByIdAsync(userId).ConfigureAwait(false);
if (user == null)
{
return null;
}
var departmentCode = user.GetDepartmentCode();
if (string.IsNullOrEmpty(departmentCode))
{
return null;
}
var deptDto = await GetByCodeAsync(departmentCode).ConfigureAwait(false);
return deptDto;
}
[AllowAnonymous]
[HttpPost("update")]
public virtual async Task UpdateAsync(DepartmentCreateInput input)

Loading…
Cancel
Save