141 lines
4.1 KiB
Go
Executable File
141 lines
4.1 KiB
Go
Executable File
package ai_text_to_novel_ctrl
|
|
|
|
import (
|
|
"91porn-server/common"
|
|
"91porn-server/common/log"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/l/operatorlgmod"
|
|
"91porn-server/web/service/ai_text_to_novel_ser"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// List doc
|
|
// @Summary 获取AI小说列表列表
|
|
// @Description 获取AI小说列表列表
|
|
// @Tags 后台-AI小说列表
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q query ai_text_to_novel_ser.WebListReq false "请求参数"
|
|
// @Success 200 object ai_text_to_novel_ser.WebListRes "成功"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/ai/text_to_novel/list [get]
|
|
func List(ctx *gin.Context) {
|
|
var req = &ai_text_to_novel_ser.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)
|
|
}
|
|
|
|
// Update doc
|
|
// @Summary 更新AI小说列表
|
|
// @Description 更新AI小说列表
|
|
// @Tags 后台-AI小说列表
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q body ai_text_to_novel_ser.WebUpdateReq false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/ai/text_to_novel/update [post]
|
|
func Update(ctx *gin.Context) {
|
|
manager, err := common.GetAdminAct(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
|
return
|
|
}
|
|
|
|
p := &ai_text_to_novel_ser.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, "AI小说列表管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|
|
|
|
// Delete doc
|
|
// @Summary 删除AI小说列表
|
|
// @Description 删除AI小说列表
|
|
// @Tags 后台-AI小说列表
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q body ai_text_to_novel_ser.WebDeleteReq false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/ai/text_to_novel/delete [post]
|
|
func Delete(ctx *gin.Context) {
|
|
manager, err := common.GetAdminAct(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
|
return
|
|
}
|
|
|
|
p := &ai_text_to_novel_ser.WebDeleteReq{}
|
|
err = ctx.ShouldBindJSON(&p)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
|
|
// 删除
|
|
err = p.Delete()
|
|
if err != nil {
|
|
if code, ok := err.(stderr.Code); ok {
|
|
common.ServeJSON(ctx, code, code.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
|
|
log, _ := json.Marshal(p)
|
|
_ = operatorlgmod.RecordOperation(manager, "AI小说列表管理", "删除", string(log), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|
|
|
|
// Callback doc
|
|
// @Summary 回调AI小说订单
|
|
// @Description 回调AI小说订单
|
|
// @Tags 后台-AI小说列表
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q body ai_text_to_novel_ser.CallbackReq false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/ai/text_to_novel/callback [post]
|
|
func Callback(ctx *gin.Context) {
|
|
var in ai_text_to_novel_ser.CallbackReq
|
|
if err := ctx.ShouldBind(&in); err != nil {
|
|
log.Error(fmt.Sprintf("ai ai_text_to_novel callback param err:%v", err))
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
err := in.Callback()
|
|
if err != nil {
|
|
log.Error(fmt.Sprintf("ai ai_text_to_novel callback err:%v", err))
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
ctx.String(http.StatusOK, stderr.Success.Msg())
|
|
}
|