Blame view

Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/DictionaryService.cs 2.35 KB
515fceeb   “wangming”   框架初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  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
  {
      /// <summary>
      /// Dictionary服务实现
      /// </summary>
      public class DictionaryService : YiCrudAppService<DictionaryEntity, DictionaryGetOutputDto, DictionaryGetListOutputDto, Guid, DictionaryGetListInputVo, DictionaryCreateInputVo, DictionaryUpdateInputVo>,
         IDictionaryService
      {
          private ISqlSugarRepository<DictionaryEntity, Guid> _repository;
          public DictionaryService(ISqlSugarRepository<DictionaryEntity, Guid> repository) : base(repository)
          {
              _repository= repository;
          }
  
          /// <summary>
          /// 查询
          /// </summary>
  
          public override async Task<PagedResultDto<DictionaryGetListOutputDto>> GetListAsync(DictionaryGetListInputVo input)
          {
              RefAsync<int> 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<DictionaryGetListOutputDto>
              {
                  TotalCount = total,
                  Items = await MapToGetListOutputDtosAsync(entities)
              };
          }
  
  
          /// <summary>
          /// 根据字典类型获取字典列表
          /// </summary>
          /// <param name="dicType"></param>
          /// <returns></returns>
          [Route("dictionary/dic-type/{dicType}")]
          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;
          }
      }
  }