using Yi.RBAC.Application.Contracts.Identity; using Cike.AutoWebApi.Setting; using Yi.RBAC.Application.Contracts.Identity.Dtos; using Yi.RBAC.Domain.Identity.Entities; using Yi.Framework.Ddd.Services; using Yi.Framework.Ddd.Dtos; using SqlSugar; using Microsoft.AspNetCore.Mvc; using Cike.AutoWebApi.Setting; namespace Yi.RBAC.Application.Identity { /// /// Dept服务实现 /// [AppService] public class DeptService : CrudAppService, IDeptService, IAutoApiService { /// /// 通过角色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 }; } } }