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.

79 lines
2.5 KiB

  1. package v1
  2. import (
  3. "gin-vue-admin/global"
  4. "gin-vue-admin/model"
  5. "gin-vue-admin/model/response"
  6. "gin-vue-admin/service"
  7. "github.com/gin-gonic/gin"
  8. "go.uber.org/zap"
  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. if err, config := service.GetSystemConfig(); err != nil {
  18. global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
  19. response.FailWithMessage("获取失败", c)
  20. } else {
  21. response.OkWithDetailed(response.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. if err := service.SetSystemConfig(sys); err != nil {
  35. global.GVA_LOG.Error("设置失败!", zap.Any("err", err))
  36. response.FailWithMessage("设置失败", 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. if err := service.SetSystemConfig(sys); err != nil {
  53. global.GVA_LOG.Error("重启系统失败!", zap.Any("err", err))
  54. response.FailWithMessage("重启系统失败", c)
  55. } else {
  56. response.OkWithMessage("重启系统成功", c)
  57. }
  58. }
  59. // @Tags System
  60. // @Summary 获取服务器信息
  61. // @Security ApiKeyAuth
  62. // @Produce application/json
  63. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  64. // @Router /system/getServerInfo [post]
  65. func GetServerInfo(c *gin.Context) {
  66. if server, err := service.GetServerInfo(); err != nil {
  67. global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
  68. response.FailWithMessage("获取失败", c)
  69. return
  70. }else {
  71. response.OkWithDetailed(gin.H{"server": server}, "获取成功", c)
  72. }
  73. }