Files
huangguo_server/web/api/productctrl/vipConfig.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

61 lines
1.7 KiB
Go

package productctrl
import (
"encoding/json"
"91porn-server/common"
"91porn-server/common/constant"
"91porn-server/common/stderr"
"91porn-server/models/l/operatorlgmod"
"91porn-server/models/v/vipconfigmod"
"github.com/gin-gonic/gin"
)
// GetConfig doc
// @Summary
// @Description 查询VIP配置
// @Tags loufeng
// @Accept mpfd,json
// @Produce json,html
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /business/getConfig [get]
func GetConfig(ctx *gin.Context) {
data, err := vipconfigmod.FindOne()
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
// SetConfig doc
// @Summary 修改配置
// @Description 修改配置
// @Tags loufeng
// @Accept mpfd,json
// @Produce json,html
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /business/setConfig [post]
func SetConfig(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
s := vipconfigmod.EditSelector{}
if err = ctx.ShouldBind(&s); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
if err = vipconfigmod.Update(s); err != nil {
common.ServeJSON(ctx, stderr.ErrDbInsertError, err.Error())
return
}
log, _ := json.Marshal(s)
_ = operatorlgmod.RecordOperation(manager, constant.VIPConfig, constant.Modify, string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, "")
}