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.

60 lines
1.9 KiB

  1. package v1
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global/response"
  5. "gin-vue-admin/model"
  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(model.System).GetSystemConfig()
  16. if err != nil {
  17. response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取失败,%v", err), c)
  18. } else {
  19. response.Result(response.SUCCESS, gin.H{"config": config}, "获取成功", c)
  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 model.System
  31. _ = c.ShouldBindJSON(&sys)
  32. err := sys.SetSystemConfig()
  33. if err != nil {
  34. response.Result(response.ERROR, gin.H{}, fmt.Sprintf("设置失败,%v", err), c)
  35. } else {
  36. response.Result(response.SUCCESS, gin.H{}, "设置成功", c)
  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 model.System
  49. _ = c.ShouldBindJSON(&sys)
  50. err := sys.SetSystemConfig()
  51. if err != nil {
  52. response.Result(response.ERROR, gin.H{}, fmt.Sprintf("设置失败,%v", err), c)
  53. } else {
  54. response.Result(response.SUCCESS, gin.H{}, "设置成功", c)
  55. }
  56. }