namespace IStation.Application
|
{
|
/// <summary>
|
/// TenantUserMapping
|
/// </summary>
|
[Route("SQI/Tenant/User/Mapping")]
|
[ApiDescriptionSettings("SQI", Name = "租户用户映射", Order = 99000)]
|
public class TenantUserMapping_Controller : IDynamicApiController
|
{
|
private readonly Service.TenantUserMapping _service = new();
|
|
/// <summary>
|
/// 通过 TenantID 获取
|
/// </summary>
|
[Route("GetByTenantID@V1.0")]
|
[HttpGet]
|
public List<TenantUserMappingDto> GetByTenantID([FromQuery][Required] TenantIDInput input)
|
{
|
var list = _service.GetByTenantID(input.TenantID);
|
var vm_list = list?.Select(x => new TenantUserMappingDto(x)).ToList();
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 UserID 获取
|
/// </summary>
|
[Route("GetByUserID@V1.0")]
|
[HttpGet]
|
public List<TenantUserMappingDto> GetByUserID([FromQuery][Required] UserIDInput input)
|
{
|
var list = _service.GetByUserID(input.UserID);
|
var vm_list = list?.Select(x => new TenantUserMappingDto(x)).ToList();
|
return vm_list;
|
}
|
|
|
#region Set
|
|
/// <summary>
|
/// 通过租户设置
|
/// </summary>
|
[Route("SetOfTenant@V1.0")]
|
[HttpPost]
|
public bool SetOfTenant([Required] SetTenantUserMappingOfTenantInput input)
|
{
|
var tenant = new Service.Tenant().GetByID(input.TenantID);
|
if (tenant == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"TenantID:{input.TenantID} 数据不存在");
|
}
|
var bol = _service.SetByTenantID(input.TenantID, input.UserIds);
|
return bol;
|
}
|
|
/// <summary>
|
/// 通过用户设置
|
/// </summary>
|
[Route("SetOfUser@V1.0")]
|
[HttpPost]
|
public bool SetOfUser([Required] SetTenantUserMappingOfUserInput input)
|
{
|
var bol = _service.SetByUserID(input.UserID, input.TenantIds);
|
return bol;
|
}
|
|
#endregion
|
|
|
}
|
}
|