65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package pagoda
|
|
|
|
import (
|
|
"context"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/redis/pipe"
|
|
"go_dreamfactory/pb"
|
|
"strconv"
|
|
|
|
"github.com/go-redis/redis/v8"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) RankListCheck(session comm.IUserSession, req *pb.PagodaRankListReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
szRank []*pb.DBPagodaRecord
|
|
rd *redis.StringSliceCmd
|
|
)
|
|
if errdata = this.RankListCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if !req.Friend {
|
|
if this.module.IsCross() {
|
|
//if conn, err := db.Cross(); err == nil {
|
|
var (
|
|
pipe *pipe.RedisPipe = this.module.modelPagoda.Redis.RedisPipe(context.TODO())
|
|
)
|
|
if req.Cid != 0 {
|
|
rd = pipe.ZRange("pagodaList"+strconv.Itoa(int(req.Cid)), 0, comm.MaxRankList)
|
|
}
|
|
|
|
if _, err := pipe.Exec(); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
_dataList := rd.Val()
|
|
for _, v := range _dataList {
|
|
//conn_, err := db.Cross()
|
|
//dbModel := db.NewDBModel(comm.TablePagodaRecord, 0, conn)
|
|
result := &pb.DBPagodaRecord{}
|
|
if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
|
szRank = append(szRank, result)
|
|
}
|
|
}
|
|
//}
|
|
}
|
|
} else {
|
|
uids := this.module.friend.GetFriendList(session.GetUserId())
|
|
for _, id := range uids {
|
|
rankData := this.module.modulerank.getPagodaRankListByFloorid(id, req.Cid)
|
|
if rankData != nil {
|
|
szRank = append(szRank, rankData)
|
|
}
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), PagodaRankListResp, &pb.PagodaRankListResp{Ranks: szRank})
|
|
return
|
|
}
|