Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
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
|
||||
VideoInfo *lid
|
||||
TransCategory *lid
|
||||
Translation *lid
|
||||
VideoCreator *lid
|
||||
Comment *lid
|
||||
HtmlText *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, "Translation", 10)
|
||||
Lid.VideoCreator = createLid(coll, "VideoCreator", 10)
|
||||
Lid.Comment = createLid(coll, "Comment", 10)
|
||||
Lid.HtmlText = createLid(coll, "HtmlText", 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
|
||||
}
|
||||
Reference in New Issue
Block a user