package mongos import ( "context" "fmt" "videoweb/pub/models/utils" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) var Lid struct { User *lid MwAcc *lid MwRole *lid MwOpLog *lid MwAccToken *lid SystemMsg *lid AdvitiseInfo *lid AdvitiseBind *lid AdvitiseLocation *lid App *lid VideoTag *lid VideoCategory *lid VideoTopic *lid VideoInfo *lid TransCategory *lid Translation *lid VideoCreator *lid Comment *lid HtmlText *lid Actress *lid Post *lid PostCategory *lid Card *lid CoinRecharge *lid RechargePackage *lid ContactUs *lid Feedback *lid VipOrder *lid CoinTrans *lid Playlet *lid PlayletChapter *lid PlayletChapterLike *lid PlayletChapterCollect *lid PlayletChapterUnlock *lid PlayletCategory *lid PlayletTheme *lid PlayletTag *lid PlayletLike *lid PlayletCollect *lid PlayletWatchProgress *lid PlayletWatchHistory *lid CommentLike *lid Announcement *lid HotSearch *lid HomeBanner *lid } func StartLid() { coll := Shop.Coll(utils.TN.GenerateId) initIndex(coll) Lid.User = createLid(coll, "user", 10) Lid.MwAcc = createLid(coll, "MwAcc", 1) Lid.MwRole = createLid(coll, "MwRole", 1) Lid.MwOpLog = createLid(coll, "MwOpLog", 10) Lid.MwAccToken = createLid(coll, "MwAccToken", 10) Lid.SystemMsg = createLid(coll, "SystemMsg", 10) Lid.AdvitiseInfo = createLid(coll, "AdvitiseInfo", 10) Lid.AdvitiseBind = createLid(coll, "AdvitiseBind", 10) Lid.AdvitiseLocation = createLid(coll, "AdvitiseLocation", 10) Lid.App = createLid(coll, "App", 10) Lid.VideoTag = createLid(coll, "VideoTag", 10) Lid.VideoCategory = createLid(coll, "VideoCategory", 10) Lid.VideoInfo = createLid(coll, "VideoInfo", 10) Lid.TransCategory = createLid(coll, "TransCategory", 10) Lid.Translation = createLid(coll, "TranslationData", 10) Lid.VideoCreator = createLid(coll, "VideoCreator", 10) Lid.Comment = createLid(coll, "Comment", 10) Lid.HtmlText = createLid(coll, "HtmlText", 10) Lid.Actress = createLid(coll, "Actress", 10) Lid.Post = createLid(coll, "Post", 10) Lid.VideoTopic = createLid(coll, "VideoTopic", 10) Lid.PostCategory = createLid(coll, "PostCategory", 10) Lid.Card = createLid(coll, "card", 10) Lid.CoinRecharge = createLid(coll, "coinRecharge", 10) Lid.RechargePackage = createLid(coll, "rechargePackage", 10) Lid.ContactUs = createLid(coll, "contactus", 10) Lid.VipOrder = createLid(coll, "vipOrder", 10) Lid.CoinTrans = createLid(coll, "coinTrans", 10) Lid.Feedback = createLid(coll, "feedback", 10) Lid.Playlet = createLid(coll, "playlet", 10) Lid.PlayletChapter = createLid(coll, "playletChapter", 10) Lid.PlayletChapterLike = createLid(coll, "playletChapterLike", 10) Lid.PlayletChapterCollect = createLid(coll, "playletChapterCollect", 10) Lid.PlayletChapterUnlock = createLid(coll, "playletChapterUnlock", 10) Lid.PlayletCategory = createLid(coll, "playletCategory", 10) Lid.PlayletTheme = createLid(coll, "playletTheme", 10) Lid.PlayletTag = createLid(coll, "playletTag", 10) Lid.PlayletLike = createLid(coll, "playletLike", 10) Lid.PlayletCollect = createLid(coll, "playletCollect", 10) Lid.PlayletWatchProgress = createLid(coll, "playletWatchProgress", 10) Lid.PlayletWatchHistory = createLid(coll, "playletWatchHistory", 10) Lid.CommentLike = createLid(coll, "commentLike", 10) Lid.Announcement = createLid(coll, "announcement", 10) Lid.HotSearch = createLid(coll, "hotSearch", 10) Lid.HomeBanner = createLid(coll, "homeBanner", 10) } // initIndex 初始化索引 func initIndex(coll *Collection) { indexes := []mongo.IndexModel{ { Keys: bson.D{ {Key: utils.FN.GenerateId.BusinessId, Value: 1}, }, Options: options.Index().SetUnique(true), }, } if _, err := coll.CreateIndex(context.Background(), indexes); err != nil { panic(fmt.Sprintf("(user:initIndex) Create Index user failed! err:%+v:", err)) } } func createLid(db *Collection, businessId string, len int) *lid { lid, err := newLid(db, businessId, len) if err != nil { panic(err) } return lid }