69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package passon
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"time"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.PassonInfoReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.PassonInfoReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBPasson
|
|
conf *cfg.GamePassonData
|
|
chanage bool
|
|
err error
|
|
)
|
|
|
|
if errdata = this.InfoCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.modelPasson.getUserPasson(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
for i, v := range info.Student {
|
|
if v.State == 2 {
|
|
if conf, err = this.module.configure.GetPassonConf(int32(i + 1)); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if int32(configure.Now().Sub(time.Unix(v.Cdtime, 0)).Hours()) >= conf.Cd {
|
|
chanage = true
|
|
v.State = 0
|
|
}
|
|
}
|
|
}
|
|
if chanage {
|
|
if err = this.module.modelPasson.updateUserPasson(session.GetUserId(), info); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.PassonInfoResp{Info: info})
|
|
return
|
|
}
|