using Microsoft.AspNetCore.Mvc;
using SqlSugar;
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;
namespace Yi.Framework.Rbac.Application.Services
{
///
/// Dictionary服务实现
///
public class DictionaryService : YiCrudAppService,
IDictionaryService
{
private ISqlSugarRepository _repository;
public DictionaryService(ISqlSugarRepository repository) : base(repository)
{
_repository= repository;
}
///
/// 查询
///
public override async Task> GetListAsync(DictionaryGetListInputVo input)
{
RefAsync total = 0;
var entities = await _repository._DbQueryable
.WhereIF(input.DictType is not null, x => x.DictType == input.DictType)
.WhereIF(input.DictLabel is not null, x => x.DictLabel!.Contains(input.DictLabel!))
.WhereIF(input.State is not null, x => x.State == input.State)
.OrderByDescending(x => x.OrderNum)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto
{
TotalCount = total,
Items = await MapToGetListOutputDtosAsync(entities)
};
}
///
/// 根据字典类型获取字典列表
///
///
///
[Route("dictionary/dic-type/{dicType}")]
public async Task> GetDicType([FromRoute] string dicType)
{
var entities = await _repository.GetListAsync(u => u.DictType == dicType && u.State == true);
var result = await MapToGetListOutputDtosAsync(entities);
return result;
}
}
}