Files
Yi.Admin/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/DictionaryService.cs

59 lines
2.3 KiB
C#
Raw Normal View History

2023-04-15 17:33:42 +08:00
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
2023-12-11 09:55:12 +08:00
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Application.Contracts.Dtos.Dictionary;
using Yi.Framework.Rbac.Application.Contracts.IServices;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
2023-04-15 17:33:42 +08:00
2023-09-15 18:05:59 +08:00
2023-12-11 09:55:12 +08:00
namespace Yi.Framework.Rbac.Application.Services
2023-04-15 17:33:42 +08:00
{
/// <summary>
/// Dictionary服务实现
/// </summary>
2023-12-11 09:55:12 +08:00
public class DictionaryService : YiCrudAppService<DictionaryEntity, DictionaryGetOutputDto, DictionaryGetListOutputDto, Guid, DictionaryGetListInputVo, DictionaryCreateInputVo, DictionaryUpdateInputVo>,
IDictionaryService
2023-04-15 17:33:42 +08:00
{
2023-12-11 09:55:12 +08:00
private ISqlSugarRepository<DictionaryEntity, Guid> _repository;
public DictionaryService(ISqlSugarRepository<DictionaryEntity, Guid> repository) : base(repository)
{
_repository= repository;
}
2023-04-15 17:33:42 +08:00
/// <summary>
/// 查询
/// </summary>
public override async Task<PagedResultDto<DictionaryGetListOutputDto>> GetListAsync(DictionaryGetListInputVo input)
{
RefAsync<int> total = 0;
2023-12-11 09:55:12 +08:00
var entities = await _repository._DbQueryable.WhereIF(input.DictType is not null, x => x.DictType == input.DictType)
2023-04-15 17:33:42 +08:00
.WhereIF(input.DictLabel is not null, x => x.DictLabel!.Contains(input.DictLabel!))
.WhereIF(input.State is not null, x => x.State == input.State)
2023-12-11 09:55:12 +08:00
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
2023-04-15 17:33:42 +08:00
return new PagedResultDto<DictionaryGetListOutputDto>
{
2023-12-11 09:55:12 +08:00
TotalCount = total,
2023-04-15 17:33:42 +08:00
Items = await MapToGetListOutputDtosAsync(entities)
};
}
/// <summary>
/// 根据字典类型获取字典列表
/// </summary>
/// <param name="dicType"></param>
/// <returns></returns>
2023-12-11 09:55:12 +08:00
[Route("dictionary/dic-type/{dicType}")]
2023-04-15 17:33:42 +08:00
public async Task<List<DictionaryGetListOutputDto>> GetDicType([FromRoute] string dicType)
{
var entities = await _repository.GetListAsync(u => u.DictType == dicType && u.State == true);
var result = await MapToGetListOutputDtosAsync(entities);
return result;
}
}
}