From 5d1f1f90a0589a065f47d033bebb36611e34cda2 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 21 Jun 2022 15:01:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mail/api.go | 7 ------- modules/mail/db_comp.go | 12 ++++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/mail/api.go b/modules/mail/api.go index f2b8af4c4..a88d08fc4 100644 --- a/modules/mail/api.go +++ b/modules/mail/api.go @@ -5,9 +5,6 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/lego/core" - - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/x/bsonx" ) const ( @@ -30,10 +27,6 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core this.service = service this.module = module.(*Mail) - //创建uid索引 - this.module.db_comp.DB.CreateIndex(core.SqlTable(DB_MailTable), mongo.IndexModel{ - Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, - }) return } diff --git a/modules/mail/db_comp.go b/modules/mail/db_comp.go index 729f6582b..d457209f7 100644 --- a/modules/mail/db_comp.go +++ b/modules/mail/db_comp.go @@ -9,7 +9,9 @@ import ( "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" + "go.mongodb.org/mongo-driver/x/bsonx" ) const ( @@ -29,6 +31,16 @@ type IMail interface { Mail_DelUserMail(objId string) bool } +func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.Model_Comp.Init(service, module, comp, options) + + //创建uid索引 + this.DB.CreateIndex(core.SqlTable(DB_MailTable), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return +} + func (this *DB_Comp) Mail_QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) { if _data, err := this.DB.Find(DB_MailTable, bson.M{"userid": uId}); err == nil {