219 lines
7.3 KiB
Go
219 lines
7.3 KiB
Go
package ai_undress_ctrl
|
|
|
|
import (
|
|
"91porn-server/app/service/ai_changeface_img_ser"
|
|
"91porn-server/app/service/ai_undress_server"
|
|
"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/models/v/aichangefaceimgmod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// List doc
|
|
// @Summary AI脱衣列表
|
|
// @Description AI脱衣列表
|
|
// @Tags AI脱衣
|
|
// @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(c *gin.Context) {
|
|
uid, err := common.GetUID(c)
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
var req aiUnDressmod.ListRequest
|
|
if err = c.ShouldBindQuery(&req); err != nil {
|
|
common.ServeJSON(c, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
data, code := ai_undress_server.List(uid, &req)
|
|
if code != stderr.Success {
|
|
log.Error(fmt.Sprintf("ai_undress_service List error%v,uid%v", code.Error(), uid))
|
|
common.ServeJSON(c, code, nil)
|
|
return
|
|
}
|
|
common.ServeJSON(c, code, data)
|
|
}
|
|
|
|
// Generate doc
|
|
// @Summary 生成AI脱衣记录
|
|
// @Description 生成AI脱衣记录
|
|
// @Tags AI脱衣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param q body aiUnDressmod.GenerateRequest false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /ai/undress/generate [post]
|
|
func Generate(ctx *gin.Context) {
|
|
uid, err := common.GetUID(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
var req aiUnDressmod.GenerateRequest
|
|
if err = ctx.ShouldBind(&req); err != nil {
|
|
log.Error(fmt.Sprintf("undress Generate param err%v\n", err))
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
ua, _ := common.GetUA(ctx)
|
|
ip := common.GetIP(ctx)
|
|
code := ai_undress_server.Generate(uid, &req, ua, ip)
|
|
if code != stderr.Success {
|
|
log.Error(fmt.Sprintf("undress Generate err%v", code))
|
|
common.ServeJSON(ctx, code, code.Error())
|
|
return
|
|
}
|
|
updateLog, _ := json.Marshal(req)
|
|
_ = operatorlgmod.RecordOperation(strconv.FormatUint(uid, 10), constant.AiUndressList, constant.Add, string(updateLog), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
|
}
|
|
|
|
// AiImgList doc
|
|
// @Summary AI换脸列表
|
|
// @Description AI换脸列表
|
|
// @Tags AI图片换脸
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param status query int false "记录状态"
|
|
// @Param pageNumber query int true "第几页"
|
|
// @Param pageSize query int true "每页数量"
|
|
// @Success 200 object aichangefaceimgmod.AiChangeFaceImg "成功后返回"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /app/ai/img/list [get]
|
|
func AiImgList(c *gin.Context) {
|
|
uid, err := common.GetUID(c)
|
|
if err != nil {
|
|
common.ServeJSON(c, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
var req aichangefaceimgmod.ListRequest
|
|
if err = c.ShouldBindQuery(&req); err != nil {
|
|
common.ServeJSON(c, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
data, code := ai_changeface_img_ser.List(uid, &req)
|
|
if code != stderr.Success {
|
|
log.Error(fmt.Sprintf("ai_change_face_service List error%v,uid%v", code.Error(), uid))
|
|
common.ServeJSON(c, code, nil)
|
|
return
|
|
}
|
|
common.ServeJSON(c, code, data)
|
|
}
|
|
|
|
// AiImgGenerate doc
|
|
// @Summary 生成AI换脸记录
|
|
// @Description 生成AI换脸记录
|
|
// @Tags AI图片换脸
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param q body aichangefaceimgmod.GenerateRequest false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /app/ai/img/generate [post]
|
|
func AiImgGenerate(ctx *gin.Context) {
|
|
uid, err := common.GetUID(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
var req aichangefaceimgmod.GenerateRequest
|
|
if err = ctx.ShouldBind(&req); err != nil {
|
|
log.Error(fmt.Sprintf("ai_change_face_img Generate param err%v\n", err))
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
ua, _ := common.GetUA(ctx)
|
|
ip := common.GetIP(ctx)
|
|
code := ai_changeface_img_ser.Generate(uid, &req, ua, ip)
|
|
if code != stderr.Success {
|
|
log.Error(fmt.Sprintf("ai_change_face_img Generate err%v", code))
|
|
common.ServeJSON(ctx, code, code.Error())
|
|
return
|
|
}
|
|
updateLog, _ := json.Marshal(req)
|
|
_ = operatorlgmod.RecordOperation(strconv.FormatUint(uid, 10), constant.AiChangeFaceImgList, constant.Add, string(updateLog), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
|
}
|
|
|
|
// AiChangeFaceImgHide doc
|
|
// @Summary 删除AI换脸记录
|
|
// @Description 删除AI换脸记录
|
|
// @Tags AI图片换脸
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id formData string false "AI订单ID"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /app/ai/img/hide [post]
|
|
func AiChangeFaceImgHide(ctx *gin.Context) {
|
|
uid, err := common.GetUID(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
var req aichangefaceimgmod.DelRequest
|
|
if err = ctx.ShouldBind(&req); err != nil {
|
|
log.Error(fmt.Sprintf("ai_change_face_img del param err%v\n", err))
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
|
|
code := ai_changeface_img_ser.AiChangeFaceImgHide(uid, &req)
|
|
if code != stderr.Success {
|
|
common.ServeJSON(ctx, code, code.Error())
|
|
return
|
|
}
|
|
updateLog, _ := json.Marshal(req)
|
|
_ = operatorlgmod.RecordOperation(strconv.FormatUint(uid, 10), constant.AiChangeFaceImgList, constant.Delete, string(updateLog), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
|
}
|
|
|
|
// AiUndressHide doc
|
|
// @Summary 删除AI换脸记录
|
|
// @Description 删除AI换脸记录
|
|
// @Tags AI脱衣
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id formData string false "AI订单ID"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /app/ai/undress/hide [post]
|
|
func AiUndressHide(ctx *gin.Context) {
|
|
uid, err := common.GetUID(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
|
return
|
|
}
|
|
var req aiUnDressmod.DelRequest
|
|
if err = ctx.ShouldBind(&req); err != nil {
|
|
log.Error(fmt.Sprintf("undress del param err%v\n", err))
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
|
|
code := ai_undress_server.AiUndressHide(uid, &req)
|
|
if code != stderr.Success {
|
|
common.ServeJSON(ctx, code, code.Error())
|
|
return
|
|
}
|
|
updateLog, _ := json.Marshal(req)
|
|
_ = operatorlgmod.RecordOperation(strconv.FormatUint(uid, 10), constant.AiUndressList, constant.Delete, string(updateLog), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, stderr.Success.Msg())
|
|
}
|