using YBEE.EQM.Core;

namespace YBEE.EQM.Application
{
    /// <summary>
    /// 字典类型服务
    /// </summary>
    public class SysDictTypeService : ISysDictTypeService, ITransient
    {
        private readonly IRepository<SysDictType> _dictTypeRep;
        public SysDictTypeService(IRepository<SysDictType> dictTypeRep)
        {
            _dictTypeRep = dictTypeRep;
        }

        /// <summary>
        /// 获取所有字典类型列表
        /// </summary>
        /// <returns></returns>
        public async Task<List<SysDictTypeOutput>> GetAllList()
        {
            var items = await _dictTypeRep.DetachedEntities.Where(u => u.Status == CommonStatus.ENABLE)
                                                        .OrderBy(u => u.Sort)
                                                        .ProjectToType<SysDictTypeOutput>()
                                                        .ToListAsync();
            return items;
        }
    }
}