54 lines
1.5 KiB
Go
54 lines
1.5 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 modelhdData struct {
|
|
modules.MCompModel
|
|
module *Activity
|
|
}
|
|
|
|
func (this *modelhdData) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TableHdData)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*Activity)
|
|
// uid 创建索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "hdid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
// 获取用户活动数据
|
|
func (this *modelhdData) getHddata(uid string) (result []*pb.DBActivityData, err error) {
|
|
result = make([]*pb.DBActivityData, 0)
|
|
if err = this.GetList(uid, &result); err != nil {
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 新增一条活动数据
|
|
func (this *modelhdData) Insert(uid string, data *pb.DBActivityData) (err error) {
|
|
if err = this.AddList(uid, data.Id, data); err != nil {
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *modelhdData) modifyActivityList(uid string, oid string, data map[string]interface{}) error {
|
|
return this.ChangeList(uid, oid, data)
|
|
}
|