Files
huangguo_server/web/api/quicksearchctrl/quicksearch.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

148 lines
4.1 KiB
Go
Executable File

package quicksearchctrl
import (
"encoding/json"
"91porn-server/common"
"91porn-server/common/stderr"
"91porn-server/models/l/operatorlgmod"
"91porn-server/web/service/quicksearchser"
"github.com/gin-gonic/gin"
)
// List doc
// @Summary 获取快捷搜索表列表
// @Description 获取快捷搜索表列表
// @Tags 后台-快捷搜索表
// @Accept mpfd,json
// @Produce json
// @Param q query quicksearchser.WebListReq false "请求参数"
// @Success 200 object quicksearchser.WebListRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Security BasicAuth
// @Router /api/web/admin/quickSearch/list [get]
func List(ctx *gin.Context) {
var req = &quicksearchser.WebListReq{}
if err := ctx.ShouldBind(&req); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
res, err := req.GetList()
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
common.ServeJSON(ctx, stderr.Success, res)
}
// Create doc
// @Summary 新增快捷搜索表
// @Description 新增快捷搜索表
// @Tags 后台-快捷搜索表
// @Accept mpfd,json
// @Produce json
// @Param q body quicksearchser.WebCreateReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Security BasicAuth
// @Router /api/web/admin/quickSearch/create [post]
func Create(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
p := &quicksearchser.WebCreateReq{}
err = ctx.ShouldBindJSON(&p)
if err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
// 创建
err = p.Create()
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
log, _ := json.Marshal(p)
_ = operatorlgmod.RecordOperation(manager, "快捷搜索表管理", "创建", string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, "")
}
// Update doc
// @Summary 更新快捷搜索表
// @Description 更新快捷搜索表
// @Tags 后台-快捷搜索表
// @Accept mpfd,json
// @Produce json
// @Param q body quicksearchser.WebUpdateReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Security BasicAuth
// @Router /api/web/admin/quickSearch/update [post]
func Update(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
p := &quicksearchser.WebUpdateReq{}
err = ctx.ShouldBindJSON(&p)
if err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
// 更新
err = p.Update()
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
log, _ := json.Marshal(p)
_ = operatorlgmod.RecordOperation(manager, "快捷搜索表管理", "更新", string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, "")
}
// Delete doc
// @Summary 删除快捷搜索表
// @Description 删除快捷搜索表
// @Tags 后台-快捷搜索表
// @Accept mpfd,json
// @Produce json
// @Param q body quicksearchser.WebDeleteReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Security BasicAuth
// @Router /api/web/admin/quickSearch/delete [post]
func Delete(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
p := &quicksearchser.WebDeleteReq{}
err = ctx.ShouldBindJSON(&p)
if err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
// 删除
err = p.Delete()
if err != nil {
common.ServeJSON(ctx, stderr.Failure, err.Error())
return
}
log, _ := json.Marshal(p)
_ = operatorlgmod.RecordOperation(manager, "快捷搜索表管理", "删除", string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, "")
}