54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package privilege
|
|
|
|
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 ModelVip struct {
|
|
modules.MCompModel
|
|
module *Privilege
|
|
}
|
|
|
|
//组件初始化接口
|
|
func (this *ModelVip) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
|
this.MCompModel.Init(service, module, comp, opt)
|
|
this.module = module.(*Privilege)
|
|
this.TableName = comm.TableVip
|
|
//创建uid索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
// 获取vip信息
|
|
func (this *ModelVip) getVipList(uid string) (vip *pb.DBVip, err error) {
|
|
vip = &pb.DBVip{}
|
|
if err = this.Get(uid, vip); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 修改Vip信息
|
|
func (this *ModelVip) modifyVipData(uid string, data map[string]interface{}) error {
|
|
return this.Change(uid, data)
|
|
}
|
|
|
|
//创建一条VIP信息
|
|
func (this *ModelVip) createVipData(uId string, vip *pb.DBVip) (err error) {
|
|
|
|
if err = this.Add(uId, vip); err != nil {
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|