Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-09-13 20:09:49 +08:00
commit 05353d57eb
8 changed files with 47 additions and 52 deletions

View File

@ -114,8 +114,10 @@ const (
TableRtask = "rtask"
// 随机任务触发记录
TableRtaskRecord = "rrecord"
///爬塔排行
TablePagodaRank = "pagodarank"
///记录用户爬塔排行数据
TablePagodaRecord = "pagodarecord"
///有序的爬塔排行 (正正的排行榜 最多只有50条)
TablePagodaRankList = "pagodaranklist"
/// 美食馆
TableSmithy = "smithy"
/// 赛季塔数据表

View File

@ -100,33 +100,20 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
mapData["pagodaId"] = cfg.LayerNum
code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData)
}
rst, _ := this.module.modulerank.GetUserRandData(session.GetUserId())
if rst.Uid == "" {
rst.Uid = session.GetUserId()
rst.Id = primitive.NewObjectID().Hex()
rst.Type = req.PagodaType
rst.Nickname = this.module.ModuleUser.GetUser(session.GetUserId()).Name
rst.Lv = this.module.ModuleUser.GetUser(session.GetUserId()).Lv
rst.PagodaId = pagoda.PagodaId
this.module.modulerank.AddRank(session.GetUserId(), rst)
} else {
if req.Report != nil && len(req.Report.Info.Redflist) > 0 {
sz := make([]*pb.LineUp, 5)
for i, v := range req.Report.Info.Redflist[0].Team {
if v != nil {
sz[i] = &pb.LineUp{
Cid: v.HeroID,
Star: v.Star,
Lv: v.Lv,
}
// 记录爬塔明细数据
if req.Report != nil && len(req.Report.Info.Redflist) > 0 {
sz := make([]*pb.LineUp, 5)
for i, v := range req.Report.Info.Redflist[0].Team {
if v != nil {
sz[i] = &pb.LineUp{
Cid: v.HeroID,
Star: v.Star,
Lv: v.Lv,
}
}
this.module.modulerank.updatePagodaRankList(session, seasonPagoda, req.Report.Info.Redflist[0].Leadpos, sz)
}
mapData["pagodaId"] = cfg.LayerNum
this.module.modulerank.ChangeUserRank(session.GetUserId(), mapData)
this.module.modulerank.addPagodaRankList(session, seasonPagoda, req.Report.Info.Redflist[0].Leadpos, sz)
}
pagoda.PagodaId = seasonPagoda.PagodaId
pagoda.Type = seasonPagoda.Type

View File

@ -14,16 +14,21 @@ func (this *apiComp) RankListCheck(session comm.IUserSession, req *pb.PagodaRank
}
func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListReq) (code pb.ErrorCode, data proto.Message) {
var (
szRank []*pb.DBPagodaRank
err error
)
code = this.RankListCheck(session, req)
if code != pb.ErrorCode_Success {
return
}
szRank, err := this.module.modulerank.GetRankData()
if err != nil {
code = pb.ErrorCode_DBError
if req.FloorId == 0 && req.Friend == false {
szRank, err = this.module.modulerank.GetRankData()
if err != nil {
code = pb.ErrorCode_DBError
}
}
session.SendMsg(string(this.module.GetType()), PagodaRankListResp, &pb.PagodaRankListResp{Ranks: szRank})
return
}

View File

@ -16,7 +16,7 @@ type ModelRank struct {
}
func (this *ModelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TablePagodaRank
this.TableName = comm.TablePagodaRecord
err = this.MCompModel.Init(service, module, comp, options)
this.modulePagoda = module.(*Pagoda)
return
@ -49,7 +49,7 @@ func (this *ModelRank) ChangeUserRank(uid string, value map[string]interface{})
func (this *ModelRank) GetRankData() (data []*pb.DBPagodaRank, err error) {
data = make([]*pb.DBPagodaRank, 0)
err = this.Redis.LRange(comm.TablePagodaRank, 0, -1, &data)
err = this.Redis.LRange(comm.TablePagodaRankList, 0, -1, &data)
return
}
@ -63,7 +63,7 @@ func (this *ModelRank) getPagodaRankList(uid string) []*pb.DBPagodaRank {
}
// 插入新的排行数据
func (this *ModelRank) updatePagodaRankList(session comm.IUserSession, data *pb.DBSeasonPagoda, Leadpos int32, line []*pb.LineUp) {
func (this *ModelRank) addPagodaRankList(session comm.IUserSession, data *pb.DBSeasonPagoda, Leadpos int32, line []*pb.LineUp) {
userinfo := this.modulePagoda.ModuleUser.GetUser(session.GetUserId())
new := &pb.DBPagodaRank{
Id: primitive.NewObjectID().Hex(),

View File

@ -61,7 +61,7 @@ func (this *ModelSeasonPagoda) addNewSeasonPagoda(uId string, data *pb.DBSeasonP
// 赛季结束 清理所有塔数据
func (this *ModelSeasonPagoda) DleAllSeasonData() {
this.DB.DeleteMany(core.SqlTable(this.TableName), bson.M{})
err := this.Redis.Ltrim(comm.TablePagodaRank, 0, -1)
err := this.Redis.Ltrim(comm.TablePagodaRecord, 0, -1)
if err != nil {
log.Errorf("delete failed")
}

View File

@ -18,7 +18,7 @@ type forumComp struct {
//组件初始化接口
func (this *forumComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TablePagodaRank
this.TableName = comm.TablePagodaRecord
this.MCompModel.Init(service, module, comp, options)
this.service = service
return

View File

@ -22,7 +22,7 @@ type PagodaRank struct {
//组件初始化接口
func (this *PagodaRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TablePagodaRank
this.TableName = comm.TablePagodaRecord
this.MCompModel.Init(service, module, comp, options)
this.service = service
return
@ -37,7 +37,7 @@ func (this *PagodaRank) Start() (err error) {
// 处理排行榜排序
func (this *PagodaRank) Timer() {
data := make([]interface{}, 0) // options.Find().SetLimit(comm.MaxRankList)
if _data, err := this.DB.Find(comm.TablePagodaRank, bson.M{}, options.Find().SetSort(bson.M{"pagodaId": -1}).SetLimit(comm.MaxRankList)); err == nil {
if _data, err := this.DB.Find(comm.TablePagodaRecord, bson.M{}, options.Find().SetSort(bson.M{"pagodaId": -1}).SetLimit(comm.MaxRankList)); err == nil {
for _data.Next(context.TODO()) {
temp := &pb.DBPagodaRank{}
if err = _data.Decode(temp); err == nil {
@ -46,9 +46,9 @@ func (this *PagodaRank) Timer() {
}
}
if len(data) > 0 {
err := this.Redis.RPush(comm.TablePagodaRank, data...)
err := this.Redis.RPush(comm.TablePagodaRankList, data...)
if err == nil {
err = this.Redis.Ltrim(comm.TablePagodaRank, -1*len(data), -1) //对一个列表进行修剪
err = this.Redis.Ltrim(comm.TablePagodaRankList, -1*len(data), -1) //对一个列表进行修剪
if err != nil {
log.Errorf("delete failed")
}

View File

@ -437,8 +437,8 @@ type PagodaRankListReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FloorId int32 `protobuf:"varint,1,opt,name=floorId,proto3" json:"floorId"` // 层数
Type int32 `protobuf:"varint,2,opt,name=type,proto3" json:"type"` // 塔类型
FloorId int32 `protobuf:"varint,1,opt,name=floorId,proto3" json:"floorId"` // 层数 0 标识总榜
Friend bool `protobuf:"varint,2,opt,name=friend,proto3" json:"friend"` // true 好友榜
}
func (x *PagodaRankListReq) Reset() {
@ -480,11 +480,11 @@ func (x *PagodaRankListReq) GetFloorId() int32 {
return 0
}
func (x *PagodaRankListReq) GetType() int32 {
func (x *PagodaRankListReq) GetFriend() bool {
if x != nil {
return x.Type
return x.Friend
}
return 0
return false
}
type PagodaRankListResp struct {
@ -575,15 +575,16 @@ var file_pagoda_pagoda_msg_proto_rawDesc = []byte{
0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73,
0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x09, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
0x22, 0x41, 0x0a, 0x11, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69,
0x22, 0x45, 0x0a, 0x11, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69,
0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x49, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x49, 0x64, 0x12,
0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74,
0x79, 0x70, 0x65, 0x22, 0x39, 0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e,
0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x05, 0x72, 0x61, 0x6e,
0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67,
0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x16, 0x0a, 0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52,
0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x22, 0x39, 0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64,
0x61, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a,
0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44,
0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, 0x72, 0x61, 0x6e,
0x6b, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (