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
+130
View File
@@ -0,0 +1,130 @@
package advanceconfigmod
import (
"91porn-server/common/db"
"91porn-server/common/log"
"91porn-server/models"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var mdb *db.MongoDB
const table = models.AdvanceConfig
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
func Init() {
mdb = db.Init(table)
initIndex()
}
func initIndex() {
many := []mongo.IndexModel{
{
Keys: bson.D{{Key: "sortCode", Value: -1}},
},
{
Keys: bson.D{{Key: "status", Value: 1}},
},
{
Keys: bson.D{{Key: "type", Value: 1}},
},
}
if _, err := coll(nil).CreateIndex(many); err != nil {
panic(fmt.Sprintf("%s model set index err ==>[%+v]", table, err))
}
}
func InsertOne(mt *db.MongoTool, cfg *AdvanceConfig) error {
if _, err := coll(mt).InsertOne(cfg); err != nil {
log.Warn(fmt.Sprintf("[METHOD-InsertOne]==> Model %s InsertOne fail error:%+v:", table, err))
return err
}
return nil
}
// FindDataByID 根据ID查询
func FindDataByID(id string) (AdvanceConfig, error) {
objID, err := primitive.ObjectIDFromHex(id)
if err != nil {
log.Warn(fmt.Sprintf("[METHOD-FindDataByID]==> Model %s ObjectIDFromHex fail error:%+v:", table, err),
log.Any("id", id),
)
return AdvanceConfig{}, err
}
var aud AdvanceConfig
if err = coll(nil).FindOne(&aud, bson.M{"_id": objID}); err != nil {
log.Warn(fmt.Sprintf("[METHOD-FindDataByID]==> Model %s FindOne fail error:%+v:", table, err),
log.Any("objID", objID),
)
return aud, err
}
return aud, nil
}
// FindDataByUID 根据UID查询
func FindDataByUID(uid uint64) ([]*AdvanceConfig, error) {
var aud []*AdvanceConfig
if err := coll(nil).Find(&aud, bson.M{"uid": uid}); err != nil {
log.Warn(fmt.Sprintf("[METHOD-FindDataByUID]==> Model %s FindOne fail error:%+v:", table, err),
log.Any("uid", uid),
)
return aud, err
}
return aud, nil
}
// QueryAllDocument 分页查询文档
func QueryAllDocument(filter primitive.M, opts ...*options.FindOptions) (out []*AdvanceConfig, 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
}
}
// IsExist 根据标签名获取标签
func IsExist(filter primitive.M) (data *AdvanceConfig, err error) {
if err = coll(nil).FindOne(&data, filter); err != nil {
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "isExist", table, "FindOne", err),
log.Any("filter", filter),
)
return nil, err
}
return data, nil
}
// Update 修改订单
func Update(t *db.MongoTool, id primitive.ObjectID, set bson.M) error {
if _, err := coll(t).UpdateOne(bson.M{"_id": id}, set); err != nil {
log.Warn(fmt.Sprintf("[METHOD-Update]==> Model %s UpdateOne fail error:%+v:", table, err),
log.Any("id", id),
log.Any("set", set),
)
return err
}
return nil
}
+51
View File
@@ -0,0 +1,51 @@
package advanceconfigmod
import (
"go.mongodb.org/mongo-driver/bson/primitive"
"time"
)
type AppAdvanceRes struct {
List []*AppAdvanceConfig `json:"list" bson:"list"` // 预售配置列表
CardList []*ProductCard `json:"cardList" bson:"cardList"` // 预售卡配置
ActivityDetail ActivityDetail `json:"activityDetail" bson:"activityDetail"` // 活动详情
}
type AppAdvanceConfig struct {
Name string `json:"name" bson:"name"` // 名称
Url string `json:"url" bson:"url"` // 配置链接
Cover string `json:"cover" bson:"cover"` // 封面
SourceURL string `form:"sourceURL" json:"sourceURL"` // 视频资源链接
Type int `json:"type" bson:"type"` // 类型 1:宣传视频,2:游戏截图,3:盲盒展示,4:花絮视频,5:下载链接
}
type ActivityDetail struct {
StartTime time.Time `json:"startTime" bson:"startTime,omitempty"` // 游戏预售开始时间
EndTime time.Time `json:"endTime" bson:"endTime,omitempty"` // 游戏预售结束时间
ActivityTime time.Time `json:"activityTime" bson:"activityTime,omitempty"` // 游戏预售活动时间
Status int `json:"status" bson:"status"` // 预售订单状态
}
type ProductCard struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"productID" ` // ID
Name string `bson:"productName" json:"productName" ` // 商品名字
Desc string `bson:"desc" json:"desc"` // 内容描述
Type int `bson:"type" json:"type"` // 会员卡类型 (1:初级,2:高级)
SendGame bool `bson:"sendGame" json:"sendGame"` // 是否赠送游戏
BGImg string `bson:"bgImg" json:"bgImg"` // 背景图
OriginalPrice int64 `bson:"originalPrice" json:"originalPrice"` // 原价
DiscountedPrice int64 `bson:"discountedPrice" json:"discountedPrice"` // 现价 单位角(金币)
DiscountedPriceIos int64 `bson:"discountedPriceIos,omitempty" json:"discountedPriceIos,omitempty"` // ios现价
DiscountedPriceAnd int64 `bson:"discountedPriceAnd,omitempty" json:"discountedPriceAnd,omitempty"` // 安卓现价
Position string `bson:"position" json:"position"` // 位置
NewPrivilege []PrivilegeInfo `bson:"newPrivilege" json:"newPrivilege"` // 新特权
GameCode []string `bson:"gameCode" json:"gameCode"` // 游戏码
IsPay bool `json:"isPay" bson:"isPay"` // 是否购买
}
// PrivilegeInfo 特权详情
type PrivilegeInfo struct {
Image string `bson:"img" json:"img"` // 特权图片
Name string `bson:"privilegeName" json:"privilegeName"` // 特权名称
Desc string `bson:"privilegeDesc" json:"privilegeDesc"` // 特权描述
}
+32
View File
@@ -0,0 +1,32 @@
package advanceconfigmod
import (
"go.mongodb.org/mongo-driver/bson/primitive"
"time"
)
type AdvanceConfig struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // ID
Name string `json:"name" bson:"name"` // 名称
Url string `json:"url" bson:"url"` // 配置链接
Cover string `json:"cover" bson:"cover"` // 封面
SourceURL string `form:"sourceURL" json:"sourceURL"` // 视频资源链接
Status int `json:"status" bson:"status"` // 配置状态 1:开启,2:关闭
Type int `json:"type" bson:"type"` // 类型 1:宣传视频,2:游戏截图,3:盲盒展示,4:花絮视频,5:下载链接
SortCode int `json:"sortCode" bson:"sortCode"` // 排序
IsDelete bool `json:"isDelete" bson:"isDelete"` // 是否删除
UpdatedAct string `json:"updatedAct" bson:"updatedAct"` // 操作用户账号
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
UpdateTime time.Time `json:"updateTime" bson:"updateTime"` // 文档更新时间
}
type AdvanceType int
const (
_ = iota
PromotionalVideo // 1 宣传视频
GameScreenshot // 2 游戏截图
BlindBox // 3 盲盒展示
SidelightsVideo // 4 花絮视频
Download // 5 下载链接
)
+126
View File
@@ -0,0 +1,126 @@
package advanceconfigmod
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)
type QueryAllCond struct {
Page int64 `form:"pageNumber" binding:"required"` // 查询页码
Limit int64 `form:"pageSize" binding:"required"` // 页码大小
Type *int `form:"type" json:"type" bson:"type,omitempty"` // 类型
Status *int `form:"status" json:"status" bson:"status,omitempty"` // 配置状态
}
type QueryAllRes struct {
List []*AdvanceConfig `json:"list"`
Total int64 `json:"total"`
}
func (receiver *QueryAllCond) Filter() bson.M {
var query = bson.M{}
if receiver.Type != nil {
query["type"] = receiver.Type
}
if receiver.Status != nil {
query["status"] = receiver.Status
}
query["isDelete"] = false
return query
}
func (receiver QueryAllCond) Options() *options.FindOptions {
return options.Find().SetSkip((receiver.Page - 1) * receiver.Limit).SetLimit(receiver.Limit).SetSort(bson.M{"sortCode": -1})
}
type WebCreateReq struct {
Name string `json:"name" bson:"name"` // 名称
Cover string `json:"cover" bson:"cover"` // 封面
SourceURL string `form:"sourceURL" json:"sourceURL"` // 视频资源链接
Status int `json:"status" bson:"status"` // 配置状态 1:开启,2:关闭
Type int `json:"type" bson:"type"` // 类型 1:宣传视频,2:游戏截图,3:盲盒展示,4:花絮视频,5:下载链接
SortCode int `json:"sortCode" bson:"sortCode"` // 排序
Url string `json:"url" bson:"url"` // 配置链接
}
// Create 发布数据fi
func (p *WebCreateReq) Create(manager string) *AdvanceConfig {
now := time.Now()
data := AdvanceConfig{
Name: p.Name,
Cover: p.Cover,
Url: p.Url,
Type: p.Type,
SourceURL: p.SourceURL,
SortCode: p.SortCode,
Status: p.Status,
IsDelete: false,
UpdatedAct: manager,
UpdateTime: now,
CreatedAt: now,
}
return &data
}
type WebUpdateReq struct {
ID string `json:"id" bson:"id" binding:"required"`
Name *string `json:"name" bson:"name,omitempty"` // 名称
Cover *string `json:"cover" bson:"cover,omitempty"` // 封面图
Type *int `json:"type" bson:"type,omitempty"` // 类型
SourceURL *string `form:"sourceURL" json:"sourceURL"` // 视频资源链接
SortCode *int `json:"sortCode" bson:"sortCode,omitempty"` // 排序
Status *int `json:"status" bson:"status,omitempty"` // 是否开启
Url *string `json:"url" bson:"url,omitempty"` // 配置链接
}
func (p *WebUpdateReq) Filter() primitive.ObjectID {
id, _ := primitive.ObjectIDFromHex(p.ID)
return id
}
func (p *WebUpdateReq) Update(updateAct string) bson.M {
var data = bson.M{}
if p.Name != nil {
data["name"] = *p.Name
}
if p.Cover != nil {
data["cover"] = *p.Cover
}
if p.SourceURL != nil {
data["sourceURL"] = *p.SourceURL
}
if p.Type != nil {
data["type"] = *p.Type
}
if p.SortCode != nil {
data["sortCode"] = *p.SortCode
}
if p.Status != nil {
data["status"] = *p.Status
}
if p.Url != nil {
data["url"] = *p.Url
}
data["updatedAct"] = updateAct
data["updateTime"] = time.Now()
return bson.M{"$set": data}
}
type WebDeleteReq struct {
ID string `json:"id" bson:"id" binding:"required"` // ID
}
func (p *WebDeleteReq) Filter() primitive.ObjectID {
id, _ := primitive.ObjectIDFromHex(p.ID)
return id
}
func (p *WebDeleteReq) Del(updateAct string) bson.M {
var data = bson.M{}
data["isDelete"] = true
data["updatedAct"] = updateAct
data["updateTime"] = time.Now()
return bson.M{"$set": data}
}