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
+57
View File
@@ -0,0 +1,57 @@
package officialWebsitemod
import (
"fmt"
"91porn-server/common/db"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
type M = bson.M
var mdb *db.MongoDB
const (
tableBasicData = "official_website_basic_data"
tableHero = "official_website_hero"
tableAlbum = "official_website_album"
tableVideo = "official_website_video"
tableTag = "official_website_tag"
tableRecruitForm = "official_website_recruit_form"
tableJobList = "official_website_job"
tableNews = "official_website_news"
tableNewsDetail = "official_website_news_detail"
tablePartner = "official_website_partner"
tableBusiness = "official_website_business"
tablePhotograph = "official_website_photograph"
)
func coll(t *db.MongoTool, tableName string) *db.MongoTool {
if t == nil {
return mdb.Coll(tableName)
}
return t.Coll(tableName)
}
func Init() {
mdb = db.Init(tableBasicData)
initIndex()
}
func initIndex() {
// 需要 seoSlug 唯一标识的表:稀疏唯一索引(空值不参与唯一约束,配合 bson omitempty)
seoSlugTables := []string{tableHero, tableAlbum, tableVideo, tablePhotograph, tableNews}
for _, table := range seoSlugTables {
if _, err := coll(nil, table).CreateIndex([]mongo.IndexModel{
{
Keys: bson.D{{Key: "seoSlug", Value: 1}},
Options: options.Index().SetUnique(true).SetSparse(true),
},
}); err != nil {
panic(fmt.Sprintf("officialWebsite seoSlug index err [%s] ==> [%+v]", table, err))
}
}
}