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.

61 lines
1.9 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. //本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
  40. // @Tags system
  41. // @Summary 设置配置文件内容
  42. // @Security ApiKeyAuth
  43. // @Produce application/json
  44. // @Param data body sysModel.System true "设置配置文件内容"
  45. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  46. // @Router /system/ReloadSystem [post]
  47. func ReloadSystem(c *gin.Context) {
  48. var sys sysModel.System
  49. _ = c.ShouldBindJSON(&sys)
  50. err := sys.SetSystemConfig()
  51. if err != nil {
  52. servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{})
  53. } else {
  54. servers.ReportFormat(c, true, "设置成功", gin.H{})
  55. }
  56. }