58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package viking
|
|
|
|
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 ModelSeasonRank struct {
|
|
modules.MCompModel
|
|
moduleViking *Viking
|
|
}
|
|
|
|
func (this *ModelSeasonRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = comm.TableVikingSRank
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.moduleViking = module.(*Viking)
|
|
//创建uid索引
|
|
this.DB.CreateIndex(core.SqlTable(comm.TableVikingSRank), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
func (this *ModelSeasonRank) AddSeasonRankList(uId string, id string, data *pb.DBVSeasonRank) (err error) {
|
|
if err = this.AddList(uId, id, data); err != nil {
|
|
return
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// 获取排行榜数据
|
|
func (this *ModelSeasonRank) getVikingSeasonRankList(uid string) []*pb.DBVSeasonRank {
|
|
ranks := make([]*pb.DBVSeasonRank, 0)
|
|
err := this.GetList(uid, &ranks)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return ranks
|
|
}
|
|
|
|
func (this *ModelSeasonRank) getVikingSeasonRankListByBossType(uid string, bossType int32) *pb.DBVSeasonRank {
|
|
ranks := make([]*pb.DBVSeasonRank, 0)
|
|
err := this.GetList(uid, &ranks)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
for _, v := range ranks {
|
|
if v.Bosstype == bossType {
|
|
return v
|
|
}
|
|
}
|
|
return nil
|
|
}
|