50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package activity
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
)
|
|
|
|
type modelHdList struct {
|
|
modules.MCompModel
|
|
module *Activity
|
|
}
|
|
|
|
func (this *modelHdList) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TableHdList)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*Activity)
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "hdid", Value: bsonx.Int32(1)}},
|
|
})
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *modelHdList) getHdList(uid string) (result []*pb.DBHuodong, err error) {
|
|
result = make([]*pb.DBHuodong, 0)
|
|
if err = this.GetList(uid, &result); err != nil {
|
|
this.module.Errorf("getActivityList db error: %v", err)
|
|
err = nil
|
|
}
|
|
return
|
|
}
|
|
|
|
// 不需要修改 此接口不调用
|
|
func (this *modelHdList) modifyHdList(uid string, data map[string]interface{}) error {
|
|
return this.Change(uid, data)
|
|
}
|
|
func (this *modelHdList) addHdList(hd *pb.DBHuodong) error {
|
|
if _, err := this.DB.InsertOne(core.SqlTable("hdinfo"), hd); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|