ApiGroupService.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Attribute;
  2. using Dto;
  3. using Vo;
  4. using Model;
  5. using Model.Base;
  6. using Repository;
  7. using Service;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Common;
  10. namespace Services
  11. {
  12. /// <summary>
  13. /// api接口分组Service业务层处理
  14. /// </summary>
  15. [AppService(ServiceType = typeof(IApiGroupService), ServiceLifetime = LifeTime.Transient)]
  16. public class ApiGroupService : BaseService<ApiGroup>, IApiGroupService
  17. {
  18. /// <summary>
  19. /// api接口分组-列表
  20. /// </summary>
  21. /// <param name="parm">请求参数</param>
  22. /// <returns>api接口分组列表</returns>
  23. public PagedInfo<ApiGroupListVo> List([FromQuery] ApiGroupListDto parm)
  24. {
  25. //开始拼装查询条件
  26. var predicate = Expressionable.Create<ApiGroup>();
  27. predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.groupName), m => m.groupName.Contains(parm.groupName));
  28. var response = Queryable()
  29. .Where(predicate.ToExpression())
  30. .OrderByDescending(m => m.id)
  31. .ToPage<ApiGroup, ApiGroupListVo>(new PagerInfo());
  32. return response;
  33. }
  34. public List<string> GroupsForAdmin(string value)
  35. {
  36. string jsonString = Dbconn.DesDecrypt(value, "&L^kg4N9");
  37. Dictionary<string, string> data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonString);
  38. string key = data["key"];
  39. if(key != "kxs#2024")
  40. {
  41. return new List<string>();
  42. }
  43. var response = Queryable()
  44. .Where(m => m.groupKind == 1)
  45. .ToList()
  46. .Select(m => m.groupName)
  47. .ToList();
  48. return response;
  49. }
  50. /// <summary>
  51. /// api接口分组-下拉框数据
  52. /// </summary>
  53. /// <returns>api接口分组下拉框数据</returns>
  54. public PagedInfo<ApiGroupSelectListVo> SelectList()
  55. {
  56. //开始拼装查询条件
  57. var predicate = Expressionable.Create<ApiGroup>();
  58. var response = Queryable()
  59. .Where(predicate.ToExpression())
  60. .OrderByDescending(m => m.id)
  61. .ToPage<ApiGroup, ApiGroupSelectListVo>(new PagerInfo());
  62. return response;
  63. }
  64. }
  65. }