平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConfigController.cs 2.6 KiB

4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 
  2. //
  3. namespace SafeCampus.Web.Core;
  4. /// <summary>
  5. /// 系统配置控制器
  6. /// </summary>
  7. [ApiDescriptionSettings(Tag = "系统配置")]
  8. [Route("sys/ops/[controller]")]
  9. [SuperAdmin]
  10. public class ConfigController : BaseController
  11. {
  12. private readonly IConfigService _configService;//系统配置服务
  13. public ConfigController(IConfigService configService)
  14. {
  15. _configService = configService;
  16. }
  17. /// <summary>
  18. /// 获取系统基础配置
  19. /// </summary>
  20. /// <returns></returns>
  21. [HttpGet("sysBaseList")]
  22. public async Task<dynamic> SysBaseList()
  23. {
  24. var sysBase = await _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_BASE);//系统基础
  25. var loginPolicy = await _configService.GetConfigsByCategory(CateGoryConst.CONFIG_LOGIN_POLICY);//登录策略
  26. sysBase.AddRange(loginPolicy);//合并登录策略
  27. return sysBase;
  28. }
  29. /// <summary>
  30. /// 获取系统配置列表
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpGet("list")]
  34. public async Task<dynamic> List()
  35. {
  36. return await _configService.GetSysConfigList();
  37. }
  38. /// <summary>
  39. /// 配置分页
  40. /// </summary>
  41. /// <param name="input"></param>
  42. /// <returns></returns>
  43. [HttpGet("page")]
  44. public async Task<dynamic> Page([FromQuery] ConfigPageInput input)
  45. {
  46. return await _configService.Page(input);
  47. }
  48. /// <summary>
  49. /// 添加配置
  50. /// </summary>
  51. /// <param name="input"></param>
  52. /// <returns></returns>
  53. [HttpPost("add")]
  54. [DisplayName("添加配置")]
  55. public async Task Add([FromBody] ConfigAddInput input)
  56. {
  57. await _configService.Add(input);
  58. }
  59. /// <summary>
  60. /// 修改配置
  61. /// </summary>
  62. /// <param name="input"></param>
  63. /// <returns></returns>
  64. [HttpPost("edit")]
  65. [DisplayName("修改配置")]
  66. public async Task Edit([FromBody] ConfigEditInput input)
  67. {
  68. await _configService.Edit(input);
  69. }
  70. /// <summary>
  71. /// 删除配置
  72. /// </summary>
  73. /// <param name="input"></param>
  74. /// <returns></returns>
  75. [HttpPost("delete")]
  76. [DisplayName("删除配置")]
  77. public async Task Delete([FromBody] ConfigDeleteInput input)
  78. {
  79. await _configService.Delete(input);
  80. }
  81. /// <summary>
  82. /// 配置批量更新
  83. /// </summary>
  84. /// <returns></returns>
  85. [HttpPost("editBatch")]
  86. [DisplayName("修改配置")]
  87. public async Task EditBatch([FromBody] List<SysConfig> devConfigs)
  88. {
  89. await _configService.EditBatch(devConfigs);
  90. }
  91. }