AppController.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Attribute;
  2. using Common;
  3. using Dto;
  4. using Vo;
  5. using Enums;
  6. using Filters;
  7. using Infrastructure;
  8. using Infrastructure.Model;
  9. using Mapster;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Middleware;
  12. using Model;
  13. using Services.Client;
  14. using Model.Base;
  15. using Base;
  16. namespace Controllers
  17. {
  18. /// <summary>
  19. /// App)Controller
  20. /// </summary>
  21. // [Route("app")]
  22. // [ApiExplorerSettings(GroupName = "App")]
  23. public class AppController : BaseController
  24. {
  25. /// <summary>
  26. /// api分组接口
  27. /// </summary>
  28. private readonly IAppBottomNavsService _AppBottomNavsService;
  29. private readonly IFileUpdateInfoService _FileUpdateInfoService;
  30. private readonly IPageUpdateInfoService _PageUpdateInfoService;
  31. public AppController(IAppBottomNavsService AppBottomNavsService,IFileUpdateInfoService FileUpdateInfoService,IPageUpdateInfoService PageUpdateInfoService)
  32. {
  33. _AppBottomNavsService = AppBottomNavsService;
  34. _FileUpdateInfoService = FileUpdateInfoService;
  35. _PageUpdateInfoService = PageUpdateInfoService;
  36. }
  37. /// <summary>
  38. /// APP底部导航列表
  39. /// </summary>
  40. /// <param name="parm">请求参数</param>
  41. /// <returns>APP底部导航列表</returns>
  42. [HttpGet]
  43. [Route("/v1/kxsconfig/app/appBottomNavs")]
  44. public IActionResult AppBottomNavs([FromQuery] AppAppBottomNavsDto parm)
  45. {
  46. var response = _AppBottomNavsService.AppBottomNavs(parm);
  47. response.Extra = new Dictionary<string, object>();
  48. response.Extra.Add("greyStyle", "");
  49. return SUCCESS(response);
  50. }
  51. /// <summary>
  52. /// APP静态资源
  53. /// </summary>
  54. /// <param name="parm">请求参数</param>
  55. /// <returns>APP静态资源</returns>
  56. [HttpGet]
  57. [Route("/v1/kxsconfig/app/staticFiles")]
  58. public IActionResult StaticFiles([FromQuery] AppStaticFilesDto parm)
  59. {
  60. var response = _FileUpdateInfoService.StaticFiles(parm);
  61. OssConfigs ossConfigs = new();
  62. AppSettings.Bind("OssConfigs", ossConfigs);
  63. foreach(var sub in response.Records)
  64. {
  65. sub.downloadUrl = ossConfigs.Host + "skin/app/" + parm.kind + "/" + sub.path + sub.fileName;
  66. sub.dataId = Function.MD5_16(sub.id.ToString() + "123890");
  67. }
  68. return SUCCESS(response);
  69. }
  70. /// <summary>
  71. /// APP页面数据检查
  72. /// </summary>
  73. /// <param name="parm">请求参数</param>
  74. /// <returns>APP页面数据检查</returns>
  75. [HttpGet]
  76. [Route("/v1/kxsconfig/app/pageInfo")]
  77. public IActionResult PageInfo([FromQuery] AppPageInfoDto parm)
  78. {
  79. OssConfigs ossConfigs = new();
  80. AppSettings.Bind("OssConfigs", ossConfigs);
  81. string modulePath = parm.modulePath + ".html";
  82. var response = _PageUpdateInfoService.Queryable()
  83. .First(x => x.modulePath == modulePath)
  84. .Adapt<AppPageInfoVo>() ?? new AppPageInfoVo();
  85. response.dataId = Function.MD5_16(response.id.ToString() + "123890");
  86. if (parm.moduleVersion < response.moduleVersion)
  87. {
  88. string PagePath = "template/app/" + parm.kind + "/" + response.modulePath;
  89. string pageContent = Function.GetNetFileContent(ossConfigs.Host + PagePath);
  90. response.moduleContent = pageContent; //模板内容
  91. }
  92. else
  93. {
  94. response.moduleContent = ""; //模板内容
  95. }
  96. return SUCCESS(response);
  97. }
  98. }
  99. }