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
+97
View File
@@ -0,0 +1,97 @@
package imagetopmod
import (
"fmt"
"91porn-server/common/db"
"91porn-server/common/log"
"91porn-server/models"
"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.ImageTop
func coll(t *db.MongoTool) *db.MongoTool {
if t == nil {
return mdb.Coll(table)
}
return t.Coll(table)
}
func initIndex() {
many := []mongo.IndexModel{
{
Keys: bson.D{{Key: "imageId", Value: 1}},
},
{
Keys: bson.D{{Key: "recommendEndTime", Value: 1}},
},
{
Keys: bson.D{{Key: "newEndTime", Value: 1}},
},
}
if _, err := coll(nil).CreateIndex(many); err != nil {
panic(fmt.Sprintf("%s model set index err ==>[%+v]", table, err))
}
}
// ThumbsUp 插入幸福广场置顶
func InsertOne(l *ImageTopModel) (err error) {
if _, err = coll(nil).InsertOne(l); err != nil {
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "InsertOne", table, "InsertOne", err))
return
}
return
}
// UpdateImageTop 更新帖子置顶信息
func UpdateImageTop(id primitive.ObjectID, update bson.M) (res *mongo.UpdateResult, err error) {
return coll(nil).UpdateOne(bson.M{"imageId": id}, bson.M{"$set": update})
}
// GetImageTopList 查询置顶帖子列表
func GetImageTopList(filter primitive.M, opts ...*options.FindOptions) (out []ImageTopModel, err error) {
if err = coll(nil).Find(&out, filter, opts...); err != nil {
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "GetImageTopList", table, "Find", err),
log.Any("filter", filter),
log.Any("opts", opts),
)
}
return
}
// GetImageTopCount 查询置顶帖子数量
func GetImageTopCount(filter primitive.M) (count int64, err error) {
if count, err = coll(nil).Count(filter); err != nil {
log.Error("imageTop location GetImageTopCount Count err", log.E(err))
return
}
return
}
// GetImageTopById 根据id查询置顶帖子列表
func GetImageTopById(id primitive.ObjectID) (imgTopInfo ImageTopModel, err error) {
if err = coll(nil).FindOne(&imgTopInfo, bson.M{"imageId": id}); err != nil {
log.Warn(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "GetImageTopById", table, "FindOne", err),
log.Any("find", id),
)
}
return
}
// DeleteOne 删除幸福广场置顶
func DeleteOne(objID primitive.ObjectID) (err error) {
if _, err = coll(nil).DeleteOne(bson.M{"imageId": objID}); err != nil {
log.Error(fmt.Sprintf("[METHOD-%s]==> Model %s %s fail error:%+v:", "DeleteOne", table, "DeleteOne", err),
log.Any("imageId", objID),
)
return
}
return
}
+107
View File
@@ -0,0 +1,107 @@
package imagetopmod
import (
"time"
"91porn-server/common/db"
"91porn-server/models/commod"
"github.com/shopspring/decimal"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func Init() {
mdb = db.Init(table)
initIndex()
}
// 帖子置顶
type ImageTopModel struct {
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // ID
ImageId primitive.ObjectID `json:"imageId" bson:"imageId"` //帖子Id
NewSort int32 `json:"newSort" bson:"newSort"` //最新排序值
RecommendSort int32 `json:"recommendSort" bson:"recommendSort"` //推荐排序值
NewEndTime *time.Time `json:"newEndTime" bson:"newEndTime"` //最新置顶结束时间
RecommendEndTime *time.Time `json:"recommendEndTime" bson:"recommendEndTime"` //推荐置顶结束时间 //推荐置顶结束时间
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` // 刷新时间
}
// 查询帖子列表请求
type ImageTopListReq struct {
TopType uint `form:"topType" json:"topType"` //1-推荐 2-最新
commod.Page
}
type ImageTopListRes struct {
Total int64 `json:"total"`
List []ImageTopResp `json:"list"`
}
// 查询帖子列表返回
type ImageTopResp struct {
ID primitive.ObjectID `json:"id" xlsx:"帖子ID"` // 帖子ID
NewsType string `json:"newsType" xlsx:"-"` // 帖子类型, VID,视频帖子,COVER
PubliserID uint64 `json:"-" xlsx:"用户ID"` // 用户ID
Title string `json:"title" xlsx:"视频标题"` // 帖子标题
SourceID string `json:"sourceID" xlsx:"-"` // 帖子源站ID
SourceURL string `json:"sourceURL" xlsx:"-"` // 帖子源站URL
FileName string `json:"fileName" xlsx:"-"` // 文件名
PlayTime uint `json:"playTime" xlsx:"总时长"` // 视频播放时长
Status int `json:"status" xlsx:"-"` // 状态,0 未审核 1通过 2审核失败 3通过并认为免费 默认为0
Cover string `json:"cover" xlsx:"-"` // 视频封面
CoverThumb string `json:"coverThumb" xlsx:"-"` // 视频封面缩略图
SeriesCover []string `json:"seriesCover" xlsx:"-"` // 封面套图
IsUser bool `json:"isUser" xlsx:"-"` // TBD
PlayCount int `json:"playCount" xlsx:"播放量(真)"` // 视频播放量(真)
LikeCount int `json:"likeCount" xlsx:"点赞量(真)"` // 视频点赞量(真)
CommentCount int `json:"commentCount" xlsx:"评论数(真)"` // 视频评论量(真)
ShareCount int `json:"shareCount" xlsx:"-"` // 视频分享量(真)
FakeLikeCount int `json:"fakeLikeCount" xlsx:"-"` // 点赞假数据
FakeCommentCount int `json:"fakeCommentCount" xlsx:"-"` // 评论假数据
FakeShareCount int `json:"fakeShareCount" xlsx:"-"` // 分享假数据
FakePlayCount int `json:"fakePlayCount" xlsx:"-"` // 播发假数据
Coins int64 `json:"coins" xlsx:"价格"` // 视频定价金币数
Resolution string `json:"resolution" xlsx:"-"` // 视频分辨率
FreeTime int `json:"freeTime" xlsx:"免费时长"` // 视频免费观看时长
Chosen bool `json:"chosen" xlsx:"-"` // 是否精选
FreeArea bool `json:"freeArea" xlsx:"-"` // 是否免费专区
Size int `json:"size" xlsx:"-"` // 文件大小 byte
CreatedAt time.Time `json:"createdAt" xlsx:"上传时间"` // 创建时间
UpdatedAt time.Time `json:"updatedAt" xlsx:"更新时间"` // 更新时间
Reason string `json:"reason" xlsx:"-"` // 审核失败的理由
IsTopping bool `json:"isTopping" xlsx:"-"` // TBD
IsRecommend bool `json:"isRecommend" xlsx:"-"` // 力荐
IsChoosen bool `json:"isChoosen" xlsx:"是否精选"` // 置精
IsMadou bool `json:"isMadou" xlsx:"-"` // 是否麻豆上传
RecoWeight int `json:"recoWeight" xlsx:"-"` // 推荐权重 -1,不可推荐
ReviewAccount string `json:"reviewAccount" xlsx:"-"` // 审核人
LinkUrl string `json:"linkUrl" xlsx:"-"` // TBD
SortCode int `json:"sortCode" xlsx:"-"` // 排序号 目前只有广告帖子有用
Rewarded decimal.Decimal `json:"rewarded" xlsx:"-"` // 打赏
FakeRewarded decimal.Decimal `json:"fakeRewarded" xlsx:"-"` // (假)获得打赏
LiaoBaTop bool `json:"liaoBaTop" xlsx:"-"` // 是否撩吧置顶
LiaoBaTopSort int `json:"liaoBaTopSort" xlsx:"-"` // 撩吧置顶排序码
WorksSort int `json:"worksSort" xlsx:"-"` // TBD
PageViewCount int64 `json:"pageViewCount" xlsx:"展现量"` // 视频页面展示次数
HitRate float64 `json:"hitRate" xlsx:"点击率"` // 视频点击率 = 页面展示次数 / 视频播放量
TagsExport string `json:"-" xlsx:"标签"` // 标签,仅用于导出
ActivityID primitive.ObjectID `json:"activityId" xlsx:"-"` // 参赛视频活动ID
NewSort int32 `json:"newSort" xlsx:"-"` //最新排序值
RecommendSort int32 `json:"recommendSort" xlsx:"-"` //推荐排序值
NewEndTime time.Time `json:"newEndTime" xlsx:"-"` //最新置顶结束时间
RecommendEndTime time.Time `json:"recommendEndTime" xlsx:"-"` //推荐置顶结束时间
}
// EditReq 更新贴子置顶列表
type EditReq struct {
ID primitive.ObjectID `form:"id" json:"id" binding:"required"` //置顶帖子id
NewSort int32 `form:"newSort" json:"newSort" binding:"omitempty"` //最新排序值
RecommendSort int32 `form:"recommendSort" json:"recommendSort" binding:"omitempty"` //推荐排序值
NewEndTime time.Time `form:"newEndTime" json:"newEndTime" binding:"omitempty"` //最新过期时间
RecommendEndTime time.Time `form:"recommendEndTime" json:"recommendEndTime" binding:"omitempty"` //推荐过期时间
}
// DeleteReq 删除置顶贴子列表请求
type DeleteReq struct {
Id primitive.ObjectID `form:"id" json:"id" binding:"required"`
}