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;
namespace Yi.Furion.Application.Rbac.Services.Impl
{
///
/// Dept服务实现
///
public class DeptService : CrudAppService,
IDeptService, ITransient, IDynamicApiController
{
///
/// 通过角色id查询该角色全部部门
///
///
//[Route("{roleId}")]
public async Task> GetListRoleIdAsync([FromRoute] long roleId)
{
var entities = await _DbQueryable.Where(d => SqlFunc.Subqueryable().Where(rd => rd.RoleId == roleId && d.Id == rd.DeptId).Any()).ToListAsync();
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
};
}
}
}