53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Dept服务实现
|
|
/// </summary>
|
|
[AppService]
|
|
public class DeptService : CrudAppService<DeptEntity, DeptGetOutputDto, DeptGetListOutputDto, long, DeptGetListInputVo, DeptCreateInputVo, DeptUpdateInputVo>,
|
|
IDeptService, IAutoApiService
|
|
{
|
|
|
|
/// <summary>
|
|
/// 通过角色id查询该角色全部部门
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
//[Route("{roleId}")]
|
|
public async Task<List<DeptGetListOutputDto>> GetListRoleIdAsync([FromRoute]long roleId)
|
|
{
|
|
var entities= await _DbQueryable.Where(d => SqlFunc.Subqueryable<RoleDeptEntity>().Where(rd => rd.RoleId == roleId && d.Id==rd.DeptId).Any()).ToListAsync();
|
|
return await MapToGetListOutputDtosAsync(entities);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 多查
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public override async Task<PagedResultDto<DeptGetListOutputDto>> GetListAsync(DeptGetListInputVo input)
|
|
{
|
|
RefAsync<int> 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<DeptGetListOutputDto>
|
|
{
|
|
Items = await MapToGetListOutputDtosAsync(entities),
|
|
Total = total
|
|
};
|
|
}
|
|
}
|
|
}
|