69 lines
2.1 KiB
Go
69 lines
2.1 KiB
Go
package system
|
|
|
|
import (
|
|
"kra/pkg/response"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type SystemApi struct{}
|
|
|
|
// GetServerInfo
|
|
// @Tags System
|
|
// @Summary 获取服务器信息
|
|
// @Security ApiKeyAuth
|
|
// @Produce application/json
|
|
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "获取服务器信息"
|
|
// @Router /system/getServerInfo [post]
|
|
func (s *SystemApi) GetServerInfo(c *gin.Context) {
|
|
serverInfo, err := systemUsecase.GetServerInfo(c.Request.Context())
|
|
if err != nil {
|
|
response.FailWithMessage("获取失败:"+err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithDetailed(gin.H{"server": serverInfo}, "获取成功", c)
|
|
}
|
|
|
|
// GetSystemConfig
|
|
// @Tags System
|
|
// @Summary 获取配置文件内容
|
|
// @Security ApiKeyAuth
|
|
// @Produce application/json
|
|
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "获取配置文件内容,返回包括系统配置"
|
|
// @Router /system/getSystemConfig [post]
|
|
func (s *SystemApi) GetSystemConfig(c *gin.Context) {
|
|
// 简化实现:返回基本配置信息
|
|
response.OkWithDetailed(gin.H{
|
|
"config": gin.H{
|
|
"system": gin.H{
|
|
"env": "production",
|
|
},
|
|
},
|
|
}, "获取成功", c)
|
|
}
|
|
|
|
// SetSystemConfig
|
|
// @Tags System
|
|
// @Summary 设置配置文件内容
|
|
// @Security ApiKeyAuth
|
|
// @Produce application/json
|
|
// @Param data body map[string]interface{} true "设置配置文件内容"
|
|
// @Success 200 {object} response.Response{msg=string} "设置配置文件内容"
|
|
// @Router /system/setSystemConfig [post]
|
|
func (s *SystemApi) SetSystemConfig(c *gin.Context) {
|
|
// 简化实现:配置设置功能
|
|
response.OkWithMessage("设置成功", c)
|
|
}
|
|
|
|
// ReloadSystem
|
|
// @Tags System
|
|
// @Summary 重载系统
|
|
// @Security ApiKeyAuth
|
|
// @Produce application/json
|
|
// @Success 200 {object} response.Response{msg=string} "重载系统"
|
|
// @Router /system/reloadSystem [post]
|
|
func (s *SystemApi) ReloadSystem(c *gin.Context) {
|
|
// 简化实现:系统重载功能
|
|
response.OkWithMessage("重载系统成功", c)
|
|
}
|