Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
@@ -0,0 +1,119 @@
package aichangefacevidmod
import (
"91porn-server/common/db"
"91porn-server/common/log"
"91porn-server/models"
"fmt"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
)
var mdb *db.MongoDB
const table = models.AiChangeFaceVideo
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
// InitARDIndex 设置账户充值流水表索引
func initIndex() {
many := []mongo.IndexModel{ //batch set indexes //value is the type 1 or -1
{
Keys: bson.D{{Key: "sort", Value: -1}},
},
{
Keys: bson.D{{Key: "createdAt", Value: -1}},
},
{
Keys: bson.D{{Key: "status", Value: -1}},
},
}
if _, err := coll(nil).CreateIndex(many); err != nil {
panic(fmt.Sprintf("AiUnDressIndex err+%v", err))
}
}
func GetMods(cond bson.M, skip, limit int) ([]AiChangeFaceVidMod, error) {
var acfms []AiChangeFaceVidMod
opts := options.Find().SetSort(bson.D{{Key: "createdAt", Value: -1}})
if skip > 0 {
opts.SetSkip(int64(skip))
}
if limit > 0 {
opts.SetLimit(int64(limit))
}
return acfms, coll(nil).Find(&acfms, cond, opts)
}
func GetValidMods(skip, limit int) ([]AiChangeFaceVidMod, error) {
var acfms []AiChangeFaceVidMod
opts := options.Find().SetSort(bson.D{{Key: "createdAt", Value: -1}})
if skip > 0 {
opts.SetSkip(int64(skip))
}
if limit > 0 {
opts.SetLimit(int64(limit))
}
return acfms, coll(nil).Find(&acfms, bson.M{"status": 1}, opts)
}
func GetAllMods() ([]AiChangeFaceVidMod, error) {
var mod []AiChangeFaceVidMod
opts := options.Find().SetSort(bson.D{{Key: "sort", Value: -1}, {Key: "createdAt", Value: -1}})
return mod, coll(nil).Find(&mod, bson.M{"status": 1}, opts)
}
func GetModById(id primitive.ObjectID) (*AiChangeFaceVidMod, error) {
var acfvm AiChangeFaceVidMod
return &acfvm, coll(nil).FindOne(&acfvm, bson.M{"_id": id})
}
func GetModByIDs(ids []primitive.ObjectID) ([]AiChangeFaceVidMod, error) {
if len(ids) == 0 {
return nil, nil
}
var acfms []AiChangeFaceVidMod
return acfms, coll(nil).Find(&acfms, bson.M{"_id": bson.M{"$in": ids}})
}
// QueryAllDocument 分页查询文档
func QueryAllDocument(filter primitive.M, opts ...*options.FindOptions) (out []*AiChangeFaceVidMod, err error) {
if err = coll(nil).Find(&out, filter, opts...); err != nil {
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "QueryAllDocument", table, "Find", err),
log.Any("filter", filter),
)
return
}
return
}
// CountDocument 查询文档条目数
func CountDocument(filter primitive.M) (int64, error) {
if count, err := coll(nil).Count(filter); err != nil {
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "CountDocument", table, "Count", err),
log.Any("filter", filter),
)
return 0, err
} else {
return count, nil
}
}
func GetAllModsByCond(filter primitive.M) ([]AiChangeFaceVidMod, error) {
var mod []AiChangeFaceVidMod
opts := options.Find().SetSort(bson.D{{Key: "sort", Value: -1}, {Key: "createdAt", Value: -1}})
return mod, coll(nil).Find(&mod, filter, opts)
}
func UpdateManyByCond(filter primitive.M, set bson.M) error {
_, err := coll(nil).UpdateMany(filter, set)
return err
}
+60
View File
@@ -0,0 +1,60 @@
package aichangefacevidmod
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
type AiChangeMod struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // AI模版ID
Title string `json:"title" bson:"title"` // 模版标题
SourceURL string `json:"sourceURL" bson:"sourceURL"` // 视频资源地址
Status int `json:"status" bson:"status"` // 状态,0 未激活 1 激活
PlayTime uint `json:"playTime" bson:"playTime"` // 影片长度
Cover string `json:"cover" bson:"cover"` // 封面大图
Type string `json:"type" bson:"type"` // 类型
ModuleType int `json:"moduleType" bson:"moduleType"` // 模块属性
HotValue int `json:"hotValue" bson:"hotValue"` // 热门值
HotMark string `json:"hotMark" bson:"hotMark"` // 热门标签
Coin uint `json:"coin" bson:"coin"` // 价格(金币)
VipCoin uint `json:"vipCoin" bson:"vipCoin"` // vip价格(金币)
}
type AiUndressMod struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // AI模版ID
Cover string `json:"cover" bson:"cover"` // AI模版图
}
type AiChangeFaceMod struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // AI模版ID
Title string `json:"title" bson:"title"` // 模版标题
Cover string `json:"cover" bson:"cover"` // AI模版图
HotValue int `json:"hotValue" bson:"hotValue"` // 热门值
HotMark string `json:"hotMark" bson:"hotMark"` // 热门标签
Coin uint `json:"coin" bson:"coin"` // 价格(金币)
VipCoin uint `json:"vipCoin" bson:"vipCoin"` // vip价格(金币)
}
type AiImgToVideoMod struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // AI模版ID
Cover string `json:"cover" bson:"cover"` // AI模版图
NewUrl string `json:"newUrl" bson:"newUrl"` // AI图生视频链接
Title string `json:"title" bson:"title"` // 模版标题
SceneType int `json:"sceneType" bson:"sceneType"` // 场景类型
}
type AiTextToImgMod struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // AI模版ID
Title string `json:"title" bson:"title"` // 模版标题
Cover string `json:"cover" bson:"cover"` // AI模版图
StyleType int `json:"styleType" bson:"styleType"` // AI绘图风格类型
ModuleType int `json:"moduleType" bson:"moduleType"` // AI模块属性类型
}
type AppResponse struct {
AiUndressMod []AiUndressMod `json:"aiUndressMod" bson:"aiUndressMod"` // AI脱衣模版
AiChangeFaceVideoMod []AiChangeMod `json:"aiChangeFaceVideoMod" bson:"aiChangeFaceVideoMod"` // AI视频换脸模型
AiChangeFaceMod []AiChangeFaceMod `json:"aiChangeFaceMod" bson:"aiChangeFaceMod"` // Ai换脸模型
AiImgToVideoMod []AiImgToVideoMod `json:"aiImgToVideoMod" bson:"aiImgToVideoMod"` // AI图生视频模型
AiTextToImgMod []AiTextToImgMod `json:"aiTextToImgMod" bson:"aiTextToImgMod"` // AI绘图模型
}
+44
View File
@@ -0,0 +1,44 @@
package aichangefacevidmod
import (
"91porn-server/common/db"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
const (
_ = iota
AIUndress // 1、AI脱衣模型配置
AIVideoChangeFace // 2、AI视频换脸配置
AIImgChangeFace // 3、AI图片换脸配置
AIImgToVideo // 4、AI图生视频配置
AITextToImage // 5、AI绘图配置
)
type AiChangeFaceVidMod struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
Title string `json:"title" bson:"title"` // 视频标题
SourceURL string `json:"sourceURL" bson:"sourceURL"` // 视频资源地址
Status int `json:"status" bson:"status"` // 状态,0 未激活 1 激活
PlayTime uint `json:"playTime" bson:"playTime"` // 影片长度
Cover string `json:"cover" bson:"cover"` // 封面大图
NewUrl string `json:"newUrl" bson:"newUrl"` // 生成后链接
StyleType int `json:"styleType" bson:"styleType"` // 风格类型
Type string `json:"type" bson:"type"` // 类型
ModuleType int `json:"moduleType" bson:"moduleType"` // 模块属性
HotValue int `json:"hotValue" bson:"hotValue"` // 热门值
HotMark string `json:"hotMark" bson:"hotMark"` // 热门标签
Coin uint `json:"coin" bson:"coin"` // 价格(金币)
VipCoin uint `json:"vipCoin" bson:"vipCoin"` // vip价格(金币)
SceneType int `json:"sceneType" bson:"sceneType"` // 场景类型
Sort int `json:"sort" bson:"sort"` // 排序
CreatedAt time.Time `json:"createdAt" bson:"createdAt,omitempty"` // 创建时间
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt,omitempty"` // 刷新时间
}
func Init() {
mdb = db.Init(table)
initIndex()
}
+91
View File
@@ -0,0 +1,91 @@
package aichangefacevidmod
import (
"91porn-server/models/commod"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type ListRequest struct {
Status *int `form:"status" json:"status"`
ModuleType *int `form:"moduleType" json:"moduleType"` // 模块属性
commod.Page
}
type AddAiChangeFaceVidReq struct {
Title string `json:"title"` // 视频标题
SourceURL string `json:"sourceURL"` // 视频资源地址
Status int `json:"status"` // 状态,0 未激活 1 激活
PlayTime uint `json:"playTime"` // 影片长度
Cover string `json:"cover"` // 封面大图
NewUrl string `json:"newUrl" bson:"newUrl"` // 生成后链接
ModuleType int `json:"moduleType" bson:"moduleType"` // 模块属性
HotValue int `json:"hotValue" bson:"hotValue"` // 热门值
HotMark string `json:"hotMark" bson:"hotMark"` // 热门标签
Type string `json:"type"` // 类型
StyleType int `json:"styleType" bson:"styleType"` // 风格类型
Coin uint `json:"coin"` // 模版价格
Sort int `json:"sort" bson:"sort"` // 排序
VipCoin uint `json:"vipCoin"` // 模版会员价格
SceneType int `json:"sceneType" form:"sceneType"` // 场景类型
}
type EditAiChangeFaceVid struct {
ID primitive.ObjectID `json:"id" binding:"required"`
Title *string `json:"title"` // 视频标题
SourceURL *string `json:"sourceURL"` // 视频资源地址
Status *int `json:"status"` // 状态,0 未激活 1 激活
PlayTime *uint `json:"playTime"` // 影片长度
Cover *string `json:"cover"` // 封面大图
ModuleType *int `json:"moduleType" bson:"moduleType"` // 模块属性
StyleType *int `json:"styleType" bson:"styleType"` // 风格类型
NewUrl *string `json:"newUrl" bson:"newUrl"` // 生成后链接
HotValue *int `json:"hotValue" bson:"hotValue"` // 热门值
HotMark *string `json:"hotMark" bson:"hotMark"` // 热门标签
Type *string `json:"type"` // 类型
Coin *uint `json:"coin"` // 模版价格
Sort *int `json:"sort" bson:"sort"` // 排序
VipCoin *uint `json:"vipCoin"` // 模版会员价格
SceneType *int `json:"sceneType" form:"sceneType"` // 场景类型
}
func AddAiChangeFaceVid(afvm AiChangeFaceVidMod) error {
_, err := coll(nil).InsertOne(afvm)
return err
}
func UpdateAiChangeFaceVid(id primitive.ObjectID, set bson.M) error {
_, err := coll(nil).UpdateOne(bson.M{"_id": id}, set)
return err
}
type WebListRequest struct {
Status *int `form:"status" json:"status" bson:"status"` // 状态
ModuleType *int `form:"moduleType" json:"moduleType" bson:"moduleType"` // 模块属性
PageNumber int64 `form:"pageNumber" json:"pageNumber"` // 第几页
PageSize int64 `form:"pageSize" json:"pageSize"` // 每页数量
}
func (receiver *WebListRequest) Filter() primitive.M {
filter := bson.M{}
if receiver.Status != nil {
filter["status"] = receiver.Status
}
if receiver.ModuleType != nil {
filter["moduleType"] = receiver.ModuleType
}
return filter
}
func (receiver *WebListRequest) Options() *options.FindOptions {
return options.Find().SetSkip((receiver.PageNumber - 1) * receiver.PageSize).SetLimit(receiver.PageSize + 1).SetSort(bson.D{{Key: "sort", Value: -1}, {Key: "createdAt", Value: -1}})
}
// 换脸订单回调请求
type CallbackReq struct {
ImgUrl string `json:"imgUrl"` //脱衣后地址
AppOrderNum string `json:"appOrderNum"` //app订单号
Msg string `json:"msg"` //消息
}