PriDatabaseSetService.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Attribute;
  2. using Model;
  3. using Model.Base;
  4. using Repository;
  5. using Service;
  6. using Microsoft.AspNetCore.Mvc;
  7. using Vo.Admin;
  8. namespace Services
  9. {
  10. /// <summary>
  11. /// 数据库连接配置Service业务层处理
  12. /// </summary>
  13. [AppService(ServiceType = typeof(IPriDatabaseSetService), ServiceLifetime = LifeTime.Transient)]
  14. public class PriDatabaseSetService : BaseService<PriDatabaseSet>, IPriDatabaseSetService
  15. {
  16. /// <summary>
  17. /// 数据库连接配置-列表
  18. /// </summary>
  19. /// <param name="param">参数请求体</param>
  20. /// <param name="page">分页参数</param>
  21. /// <returns>列表</returns>
  22. public PagedInfo<GetPriDatabaseSetListVo> getPriDatabaseSetList([FromQuery] PagerInfo page, [FromQuery] PriDatabaseSet param)
  23. {
  24. //拼装查询条件
  25. var predicate = Expressionable.Create<PriDatabaseSet>();
  26. predicate = predicate.AndIF(!string.IsNullOrEmpty(param.ipAddress), m => m.ipAddress.Contains(param.ipAddress));
  27. predicate = predicate.AndIF(!string.IsNullOrEmpty(param.userId), m => m.userId.Contains(param.userId));
  28. predicate = predicate.AndIF(param.projectId > 0, m => m.projectId == param.projectId);
  29. var response = Queryable()
  30. .Where(predicate.ToExpression())
  31. .OrderByDescending(m => m.id)
  32. .ToPage<PriDatabaseSet, GetPriDatabaseSetListVo>(page);
  33. return response;
  34. }
  35. /// <summary>
  36. /// 数据库连接配置-下拉框数据
  37. /// </summary>
  38. /// <param name="page">分页参数</param>
  39. /// <returns>下拉框数据</returns>
  40. public PagedInfo<GetPriDatabaseSetDicVo> getPriDatabaseSetDic([FromQuery] PagerInfo page)
  41. {
  42. //拼装查询条件
  43. var predicate = Expressionable.Create<PriDatabaseSet>();
  44. var response = Queryable()
  45. .Where(predicate.ToExpression())
  46. .OrderByDescending(m => m.id)
  47. .ToPage<PriDatabaseSet, GetPriDatabaseSetDicVo>(page);
  48. return response;
  49. }
  50. }
  51. }