diff --git a/comm/const.go b/comm/const.go index 55ea51491..7428fa987 100644 --- a/comm/const.go +++ b/comm/const.go @@ -141,6 +141,7 @@ const ( TableSeasonRecord = "seasonRecord" // 赛季塔记录 /// 美食馆 TableSmithy = "smithy" + TableSmithyTrade = "trade" /// 赛季塔数据表 TableSeasonPagoda = "seasonpagoda" // diff --git a/modules/smithy/model_trade.go b/modules/smithy/model_trade.go new file mode 100644 index 000000000..2254a8b27 --- /dev/null +++ b/modules/smithy/model_trade.go @@ -0,0 +1,27 @@ +package smithy + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" + + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" +) + +type modelTrade struct { + modules.MCompModel + module *Smithy +} + +func (this *modelTrade) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = string(comm.TableSmithyTrade) + err = this.MCompModel.Init(service, module, comp, options) + this.module = module.(*Smithy) + // uid 创建索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return +} +// \ No newline at end of file diff --git a/modules/smithy/module.go b/modules/smithy/module.go index 1bcebeaaf..319c74782 100644 --- a/modules/smithy/module.go +++ b/modules/smithy/module.go @@ -15,6 +15,7 @@ import ( type Smithy struct { modules.ModuleBase modelSmithy *modelSmithy + modelTrade *modelTrade api *apiComp configure *configureComp } @@ -38,6 +39,7 @@ func (this *Smithy) OnInstallComp() { this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelSmithy = this.RegisterComp(new(modelSmithy)).(*modelSmithy) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) + this.modelTrade = this.RegisterComp(new(modelTrade)).(*modelTrade) } // 接口信息