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.

59 lines
1.7 KiB

  1. package api
  2. import (
  3. "fmt"
  4. "gin-vue-admin/controller/servers"
  5. "gin-vue-admin/model/sysModel"
  6. "github.com/gin-gonic/gin"
  7. )
  8. // @Tags system
  9. // @Summary 获取配置文件内容
  10. // @Security ApiKeyAuth
  11. // @Produce application/json
  12. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  13. // @Router /system/getSystemConfig [post]
  14. func GetSystemConfig(c *gin.Context) {
  15. err, config := new(sysModel.System).GetSystemConfig()
  16. if err != nil {
  17. servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{})
  18. } else {
  19. servers.ReportFormat(c, true, "获取成功", gin.H{"config": config})
  20. }
  21. }
  22. // @Tags system
  23. // @Summary 设置配置文件内容
  24. // @Security ApiKeyAuth
  25. // @Produce application/json
  26. // @Param data body sysModel.System true
  27. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  28. // @Router /system/setSystemConfig [post]
  29. func SetSystemConfig(c *gin.Context) {
  30. var sys sysModel.System
  31. _ = c.ShouldBindJSON(&sys)
  32. err := sys.SetSystemConfig()
  33. if err != nil {
  34. servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{})
  35. } else {
  36. servers.ReportFormat(c, true, "设置成功", gin.H{})
  37. }
  38. }
  39. // @Tags system
  40. // @Summary 设置配置文件内容
  41. // @Security ApiKeyAuth
  42. // @Produce application/json
  43. // @Param data body sysModel.System true
  44. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  45. // @Router /system/ReloadSystem [post]
  46. func ReloadSystem(c *gin.Context) {
  47. var sys sysModel.System
  48. _ = c.ShouldBindJSON(&sys)
  49. err := sys.SetSystemConfig()
  50. if err != nil {
  51. servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{})
  52. } else {
  53. servers.ReportFormat(c, true, "设置成功", gin.H{})
  54. }
  55. }