package ai_text_to_novel_ctrl import ( "91porn-server/app/service/ai_text_to_novel_ser" "91porn-server/common" "91porn-server/common/log" "91porn-server/common/stderr" "fmt" "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.AppQueryListReq false "请求参数" // @Success 200 object ai_text_to_novel_ser.AppListRes "成功" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/app/ai_text_to_novel/list [get] func List(ctx *gin.Context) { p := &ai_text_to_novel_ser.AppQueryListReq{} if err := ctx.ShouldBind(&p); err != nil { common.ServeJSON(ctx, stderr.ErrParamError, nil) return } // 获取用户当前配置 var err error p.UID, err = common.GetUID(ctx) if err != nil { common.ServeJSON(ctx, stderr.ErrNoToken, err) return } list := p.GetList() common.ServeJSON(ctx, stderr.Success, list) } // Info doc // @Summary 获取AI小说列表详情接口 // @Description 获取AI小说列表详情 // @Tags 移动端-AI小说列表 // @Accept mpfd,json // @Produce json // @Param q query ai_text_to_novel_ser.AppQueryInfoReq false "请求参数" // @Success 200 object ai_text_to_novel_ser.AppQueryInfoRes "成功" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/app/ai_text_to_novel/info [get] func Info(ctx *gin.Context) { p := &ai_text_to_novel_ser.AppQueryInfoReq{} if err := ctx.ShouldBind(&p); err != nil { common.ServeJSON(ctx, stderr.ErrParamError, nil) return } data, err := p.GetInfo() if err != nil { common.ServeJSON(ctx, stderr.Failure, err.Error()) return } common.ServeJSON(ctx, stderr.Success, data) } // Generate doc // @Summary 生成AI小说订单记录 // @Description 生成AI小说订单记录 // @Tags 移动端-AI小说列表 // @Accept json // @Produce json // @Param q body ai_text_to_novel_ser.GenerateReq false "请求参数" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/app/ai_text_to_novel/generate [post] func Generate(ctx *gin.Context) { uid, err := common.GetUID(ctx) if err != nil { common.ServeJSON(ctx, stderr.ErrNoToken, err) return } in := ai_text_to_novel_ser.GenerateReq{} if err = ctx.ShouldBind(&in); err != nil { log.Error(fmt.Sprintf("ai_text_to_novel Generate param err:%v\n", err)) common.ServeJSON(ctx, stderr.ErrParamError, err) return } in.UID = uid ua, _ := common.GetUA(ctx) ip := common.GetIP(ctx) code, err := in.Generate(ua, ip) if err != nil { log.Error(fmt.Sprintf("ai_text_to_novel Generate err:%v\n", err)) common.ServeJSON(ctx, code, err.Error()) return } common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg()) } // Hide doc // @Summary 删除AI小说记录 // @Description 删除AI小说记录 // @Tags 移动端-AI小说列表 // @Accept json // @Produce json // @Param q body ai_text_to_novel_ser.HideReq false "请求参数" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/app/ai_text_to_novel/hide [post] func Hide(ctx *gin.Context) { uid, err := common.GetUID(ctx) if err != nil { common.ServeJSON(ctx, stderr.ErrNoToken, err) return } in := ai_text_to_novel_ser.HideReq{} if err = ctx.ShouldBind(&in); err != nil { log.Error(fmt.Sprintf("ai_text_to_novel hide param err:%v\n", err)) common.ServeJSON(ctx, stderr.ErrParamError, err) return } in.UID = uid err = in.Hide() if err != nil { log.Error(fmt.Sprintf("ai_text_to_novel hide err:%v\n", err)) if code, ok := err.(stderr.Code); ok { common.ServeJSON(ctx, code, code.Error()) return } common.ServeJSON(ctx, stderr.Failure, err) return } common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg()) }