sys_system.go 1.9 KB

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