@@ -0,0 +1,213 @@
|
||||
package ai_undress_ctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/aiUnDressmod"
|
||||
"91porn-server/web/service/ai_undress_service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
// @Summary AI脱衣列表
|
||||
// @Description AI脱衣列表
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query int false "记录状态"
|
||||
// @Param pageNumber query int true "第几页"
|
||||
// @Param pageSize query int true "每页数量"
|
||||
// @Success 200 object interface{} "成功后返回"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/undress/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.WebListRequest
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
data, code := ai_undress_service.List(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai_undress_service web List error%v,manager%v", code.Error(), manager))
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 生成AI脱衣记录
|
||||
// @Description 生成AI脱衣记录
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param originPic formData string false "脱衣原图"
|
||||
// @Param coin formData string false "金币价格"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/undress/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.EditCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress Generate param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
code := ai_undress_service.Update(manager, &req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiUndressList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Auto doc
|
||||
// @Summary 生成AI脱衣记录,自动处理
|
||||
// @Description 生成AI脱衣记录,自动处理
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param originPic formData string false "脱衣原图"
|
||||
// @Param coin formData string false "金币价格"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/undress/auto [post]
|
||||
func Auto(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.AutoCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress auto Generate param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
code := ai_undress_service.Auto(manager, &req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress auto err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiUndressList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Update doc
|
||||
// @Summary 生成AI脱衣记录,批量自动处理
|
||||
// @Description 生成AI脱衣记录,批量自动处理
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param ids formData []string false "id列表"
|
||||
// @Param pass formData bool false "是否通过"
|
||||
// @Param remark formData string false "不通过的原因"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/ai/undress/auto/batch [post]
|
||||
func AutoBatch(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var req aiUnDressmod.AutoBatchCond
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress auto Generate param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
w := &sync.WaitGroup{}
|
||||
errCodes := []stderr.Code{}
|
||||
lock := &sync.Mutex{}
|
||||
for _, v := range req.IDs {
|
||||
w.Add(1)
|
||||
id := v
|
||||
common.Go(func() {
|
||||
defer w.Done()
|
||||
if !req.Pass {
|
||||
status := aiUnDressmod.FAILURE
|
||||
// 拒绝
|
||||
code := ai_undress_service.Update(manager, &aiUnDressmod.EditCond{
|
||||
ID: id,
|
||||
Status: &status,
|
||||
Remark: &req.Remark,
|
||||
})
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
errCodes = append(errCodes, code)
|
||||
return
|
||||
}
|
||||
// 审核通过
|
||||
code := ai_undress_service.Auto(manager, &aiUnDressmod.AutoCond{
|
||||
ID: id,
|
||||
})
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
errCodes = append(errCodes, code)
|
||||
})
|
||||
}
|
||||
w.Wait()
|
||||
|
||||
for _, code := range errCodes {
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress auto err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
updateLog, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.AiUndressList, constant.Modify, string(updateLog), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// Callback doc
|
||||
// @Summary AI脱衣回调,自动服务
|
||||
// @Description AI脱衣回调,自动服务
|
||||
// @Tags AI脱衣-WEB
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param originPic formData string false "脱衣原图"
|
||||
// @Param coin formData string false "金币价格"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ai/undress/callback [post]
|
||||
func Callback(ctx *gin.Context) {
|
||||
var req aiUnDressmod.CallBackReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
log.Error(fmt.Sprintf("ai undress update param err%v\n", err))
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code := ai_undress_service.CallBackOrder(&req)
|
||||
if code != stderr.Success {
|
||||
log.Error(fmt.Sprintf("ai undress Update err%v", code))
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
ctx.String(200, "success")
|
||||
}
|
||||
Reference in New Issue
Block a user