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.

62 lines
1.8 KiB

  1. package v1
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global/response"
  5. "gin-vue-admin/model"
  6. resp "gin-vue-admin/model/response"
  7. "gin-vue-admin/service"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // @Tags system
  11. // @Summary 获取配置文件内容
  12. // @Security ApiKeyAuth
  13. // @Produce application/json
  14. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  15. // @Router /system/getSystemConfig [post]
  16. func GetSystemConfig(c *gin.Context) {
  17. err, config := service.GetSystemConfig()
  18. if err != nil {
  19. response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
  20. } else {
  21. response.OkWithData(resp.SysConfigResponse{Config: config}, c)
  22. }
  23. }
  24. // @Tags system
  25. // @Summary 设置配置文件内容
  26. // @Security ApiKeyAuth
  27. // @Produce application/json
  28. // @Param data body model.System true "设置配置文件内容"
  29. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  30. // @Router /system/setSystemConfig [post]
  31. func SetSystemConfig(c *gin.Context) {
  32. var sys model.System
  33. _ = c.ShouldBindJSON(&sys)
  34. err := service.SetSystemConfig(sys)
  35. if err != nil {
  36. response.FailWithMessage(fmt.Sprintf("设置失败,%v", err), c)
  37. } else {
  38. response.OkWithData("设置成功", c)
  39. }
  40. }
  41. // 本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
  42. // @Tags system
  43. // @Summary 设置配置文件内容
  44. // @Security ApiKeyAuth
  45. // @Produce application/json
  46. // @Param data body model.System true "设置配置文件内容"
  47. // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
  48. // @Router /system/ReloadSystem [post]
  49. func ReloadSystem(c *gin.Context) {
  50. var sys model.System
  51. _ = c.ShouldBindJSON(&sys)
  52. err := service.SetSystemConfig(sys)
  53. if err != nil {
  54. response.FailWithMessage(fmt.Sprintf("设置失败,%v", err), c)
  55. } else {
  56. response.OkWithMessage("设置成功", c)
  57. }
  58. }