using SqlSugar;
using Yi.Framework.Infrastructure.Ddd.Dtos;
using Yi.Framework.Infrastructure.Ddd.Services;
using Yi.Furion.Core.Rbac.Dtos.Dept;
using Yi.Furion.Core.Rbac.Entities;
using Yi.Furion.Sqlsugar.Core.Repositories;
namespace Yi.Furion.Application.Rbac.Services.Impl
{
///
/// Dept服务实现
///
[ApiDescriptionSettings("RBAC")]
public class DeptService : CrudAppService,
IDeptService, ITransient, IDynamicApiController
{
private IDeptRepository _deptRepository;
public DeptService(IDeptRepository deptRepository) { _deptRepository = deptRepository; }
[NonAction]
public async Task> GetChildListAsync(long deptId)
{
return await _deptRepository.GetChildListAsync(deptId);
}
///
/// 通过角色id查询该角色全部部门
///
///
//[Route("{roleId}")]
public async Task> GetRoleIdAsync([FromRoute] long roleId)
{
var entities = await _deptRepository.GetListRoleIdAsync(roleId);
return await MapToGetListOutputDtosAsync(entities);
}
///
/// 多查
///
///
///
public override async Task> GetListAsync(DeptGetListInputVo input)
{
RefAsync total = 0;
var entities = await _DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
.WhereIF(input.State is not null, u => u.State == input.State)
.OrderBy(u => u.OrderNum, OrderByType.Asc)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto
{
Items = await MapToGetListOutputDtosAsync(entities),
Total = total
};
}
}
}