mirror of https://github.com/Xhofe/alist
49 lines
961 B
Go
49 lines
961 B
Go
package controllers
|
|
|
|
import (
|
|
"github.com/Xhofe/alist/model"
|
|
"github.com/Xhofe/alist/server/common"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func SaveSettings(c *gin.Context) {
|
|
var req []model.SettingItem
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
common.ErrorResp(c, err, 400)
|
|
return
|
|
}
|
|
if err := model.SaveSettings(req); err != nil {
|
|
common.ErrorResp(c, err, 500)
|
|
} else {
|
|
model.LoadSettings()
|
|
common.SuccessResp(c)
|
|
}
|
|
}
|
|
|
|
func GetSettings(c *gin.Context) {
|
|
settings, err := model.GetSettings()
|
|
if err != nil {
|
|
common.ErrorResp(c, err, 400)
|
|
return
|
|
}
|
|
common.SuccessResp(c, settings)
|
|
}
|
|
|
|
func GetSettingsPublic(c *gin.Context) {
|
|
settings, err := model.GetSettingsPublic()
|
|
if err != nil {
|
|
common.ErrorResp(c, err, 400)
|
|
return
|
|
}
|
|
common.SuccessResp(c, settings)
|
|
}
|
|
|
|
func DeleteSetting(c *gin.Context) {
|
|
key := c.Query("key")
|
|
if err := model.DeleteSetting(key); err != nil {
|
|
common.ErrorResp(c, err, 500)
|
|
return
|
|
}
|
|
common.SuccessResp(c)
|
|
}
|