Initial commit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 10:47:18 +08:00
co-authored by Claude Opus 4.7
commit 79ac89b458
708 changed files with 151634 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
package mwacc
import (
"context"
"fmt"
"videoweb/pub/mongos"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
// Init 初始化数据
func Init(ctx context.Context) {
mwAccColl = mongos.Shop.Coll(TN.MwAcc)
mwRoleColl = mongos.Shop.Coll(TN.MwRole)
mwAccTokenColl = mongos.Shop.Coll(TN.MwAccToken)
initIndex(ctx)
return
}
// initIndex 初始化索引
func initIndex(ctx context.Context) {
initAccIndex(ctx)
initRoleIndex(ctx)
initAccTokenIndex(ctx)
}
func initAccIndex(ctx context.Context) {
indexes := []mongo.IndexModel{
{
Keys: bson.D{
{FN.MwAcc.Id, 1},
},
},
}
if _, err := mwAccColl.CreateIndex(ctx, indexes); err != nil {
panic(fmt.Sprintf("(mwacc:initAccIndex) Create mwacc Index failed! err:%+v:", err))
}
}
func initRoleIndex(ctx context.Context) {
indexes := []mongo.IndexModel{
{
Keys: bson.D{
{FN.MwRole.Id, 1},
},
// Options: options.Index().SetUnique(true),
},
}
if _, err := mwRoleColl.CreateIndex(ctx, indexes); err != nil {
panic(fmt.Sprintf("(mwacc:initRoleIndex) Create mwacc Index failed! err:%+v:", err))
}
}
func initAccTokenIndex(ctx context.Context) {
indexes := []mongo.IndexModel{
{
Keys: bson.D{
{FN.MwAccToken.Id, 1},
},
// Options: options.Index().SetUnique(true),
},
}
if _, err := mwAccTokenColl.CreateIndex(ctx, indexes); err != nil {
panic(fmt.Sprintf("(mwacc:initAccTokenIndex) Create mwacc Index failed! err:%+v:", err))
}
}