52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"gitee.ltd/lxh/logger/log"
|
|
"github.com/gin-gonic/gin"
|
|
"wireguard-dashboard/http/param"
|
|
"wireguard-dashboard/repository"
|
|
"wireguard-dashboard/utils"
|
|
)
|
|
|
|
type setting struct{}
|
|
|
|
func Setting() setting {
|
|
return setting{}
|
|
}
|
|
|
|
// GetGlobalSetting
|
|
// @description: 获取全局设置配置
|
|
// @receiver setting
|
|
// @param c
|
|
func (setting) GetGlobalSetting(c *gin.Context) {
|
|
data, err := repository.System().GetServerSetting()
|
|
if err != nil {
|
|
log.Errorf("获取配置失败: %v", err.Error())
|
|
}
|
|
|
|
utils.GinResponse(c).OKWithData(data)
|
|
}
|
|
|
|
// SetGlobalServerSetting
|
|
// @description: 设置全局服务配置
|
|
// @receiver setting
|
|
// @param c
|
|
func (setting) SetGlobalServerSetting(c *gin.Context) {
|
|
var p param.SetSetting
|
|
if err := c.ShouldBind(&p); err != nil {
|
|
utils.GinResponse(c).FailedWithErr("参数错误", err)
|
|
return
|
|
}
|
|
|
|
}
|
|
|
|
// GetPublicNetworkIP
|
|
// @description: 获取当前机器的公网IP
|
|
// @receiver setting
|
|
// @param c
|
|
func (setting) GetPublicNetworkIP(c *gin.Context) {
|
|
utils.GinResponse(c).OKWithData(map[string]string{
|
|
"IP": utils.Network().GetHostPublicIP(),
|
|
})
|
|
}
|