Files
Yi.Admin/Yi.Furion.Net6/Yi.Furion.Application/Rbac/Services/Impl/DeptService.cs

56 lines
2.2 KiB
C#
Raw Normal View History

2023-04-13 21:12:06 +08:00
using SqlSugar;
using Yi.Framework.Infrastructure.Ddd.Dtos;
using Yi.Framework.Infrastructure.Ddd.Services;
2023-04-15 22:44:33 +08:00
using Yi.Furion.Core.Rbac.Dtos.Dept;
2023-04-15 17:33:42 +08:00
using Yi.Furion.Core.Rbac.Entities;
2023-05-22 12:57:27 +08:00
using Yi.Furion.Sqlsugar.Core.Repositories;
2023-04-13 21:12:06 +08:00
2023-04-15 17:33:42 +08:00
namespace Yi.Furion.Application.Rbac.Services.Impl
2023-04-13 21:12:06 +08:00
{
/// <summary>
/// Dept服务实现
/// </summary>
public class DeptService : CrudAppService<DeptEntity, DeptGetOutputDto, DeptGetListOutputDto, long, DeptGetListInputVo, DeptCreateInputVo, DeptUpdateInputVo>,
IDeptService, ITransient, IDynamicApiController
{
2023-05-22 12:57:27 +08:00
private IDeptRepository _deptRepository;
public DeptService(IDeptRepository deptRepository) { _deptRepository = deptRepository; }
2023-05-21 13:16:04 +08:00
[NonAction]
public async Task<List<long>> GetChildListAsync(long deptId)
2023-05-21 13:16:04 +08:00
{
2023-05-22 12:57:27 +08:00
return await _deptRepository.GetChildListAsync(deptId);
2023-05-21 13:16:04 +08:00
}
2023-04-13 21:12:06 +08:00
/// <summary>
/// 通过角色id查询该角色全部部门
/// </summary>
/// <returns></returns>
//[Route("{roleId}")]
2023-05-22 13:03:09 +08:00
public async Task<List<DeptGetListOutputDto>> GetRoleIdAsync([FromRoute] long roleId)
2023-04-13 21:12:06 +08:00
{
2023-05-22 12:57:27 +08:00
var entities = await _deptRepository.GetListRoleIdAsync(roleId);
2023-04-13 21:12:06 +08:00
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
};
}
}
}