更新测试

This commit is contained in:
wh_zcy 2022-09-01 14:58:20 +08:00
parent 6b4dae65e6
commit 8c11261751
15 changed files with 402 additions and 140 deletions

View File

@ -7,14 +7,6 @@
"data2": 0,
"data3": 0
},
{
"id": 102,
"datatype": 1,
"type": 1,
"data1": 25001,
"data2": 0,
"data3": 0
},
{
"id": 103,
"datatype": 1,
@ -47,14 +39,6 @@
"data2": 2,
"data3": 0
},
{
"id": 107,
"datatype": 1,
"type": 1,
"data1": 25001,
"data2": 0,
"data3": 0
},
{
"id": 108,
"datatype": 1,

View File

@ -18,6 +18,7 @@ import (
"strings"
"fyne.io/fyne/v2"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
)
@ -81,6 +82,7 @@ var (
ff(comm.ModuleRtask, rtask.RtaskSubTypeApply): &formview.RtaskDoitView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose): &formview.RtaskChooseView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward): &formview.RtaskRewardView{},
ff(comm.ModuleRtask, "rtest"): &formview.RtaskTestView{},
}
)
@ -161,6 +163,7 @@ var (
ff(comm.ModuleRtask, rtask.RtaskSubTypeApply),
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose),
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward),
ff(comm.ModuleRtask, "rtest"),
},
}
)
@ -196,8 +199,17 @@ var (
Req: &pb.UserModifynameReq{},
Rsp: &pb.UserModifynameResp{},
Print: func(rsp proto.Message) string {
r := rsp.(*pb.UserModifynameResp)
return fmt.Sprintf("Uid:%s count:%d", r.Uid, r.Count)
logrus.WithFields(logrus.Fields{"main": "user", "stype": "modifyname"}).Debug("print")
var formatStr strings.Builder
if in, ok := rsp.(*pb.UserMessage); ok {
out := &pb.UserModifynameResp{}
if !comm.ProtoUnmarshal(in, out) {
return errors.New("unmarshal err").Error()
}
formatStr.WriteString(fmt.Sprintf("Uid:%s count:%d", out.Uid, out.Count))
}
return formatStr.String()
},
Enabled: true,
},
@ -292,15 +304,17 @@ var (
Rsp: &pb.TaskListResp{},
Enabled: true,
Print: func(rsp proto.Message) string {
in := rsp.(*pb.UserMessage)
out := &pb.TaskListResp{}
if !comm.ProtoUnmarshal(in, out) {
return errors.New("unmarshal err").Error()
}
logrus.WithFields(logrus.Fields{"main": "task", "stype": "list"}).Debug("print")
var formatStr strings.Builder
for i, v := range out.List {
formatStr.WriteString(fmt.Sprintf("%d- %v\n", (i + 1), v))
if in, ok := rsp.(*pb.UserMessage); ok {
out := &pb.TaskListResp{}
if !comm.ProtoUnmarshal(in, out) {
return errors.New("unmarshal err").Error()
}
for i, v := range out.List {
formatStr.WriteString(fmt.Sprintf("%d- %v\n", (i + 1), v))
}
}
return formatStr.String()
},
@ -335,15 +349,16 @@ var (
MainType: string(comm.ModuleHero),
SubType: hero.HeroSubTypeList,
Print: func(rsp proto.Message) string {
in := rsp.(*pb.UserMessage)
out := &pb.HeroListResp{}
if !comm.ProtoUnmarshal(in, out) {
return errors.New("unmarshal err").Error()
}
logrus.WithFields(logrus.Fields{"main": comm.ModuleHero, "stype": hero.HeroSubTypeList}).Debug("print")
var formatStr strings.Builder
for i, v := range out.List {
formatStr.WriteString(fmt.Sprintf("%d- %v\n", (i + 1), v))
if in, ok := rsp.(*pb.UserMessage); ok {
out := &pb.HeroListResp{}
if !comm.ProtoUnmarshal(in, out) {
return errors.New("unmarshal err").Error()
}
for i, v := range out.List {
formatStr.WriteString(fmt.Sprintf("%d- %v\n", (i + 1), v))
}
}
return formatStr.String()
},
@ -570,6 +585,13 @@ var (
SubType: rtask.RtaskSubTypeReward,
Enabled: true,
},
ff(comm.ModuleRtask, "rtest"): {
NavLabel: "测试",
Desc: "测试任务触发",
MainType: string(comm.ModuleRtask),
SubType: "rtest",
Enabled: true,
},
}
)

View File

@ -0,0 +1,51 @@
package formview
import (
"errors"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
)
type RtaskTestView struct {
BaseformView
}
func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
rtaskTypeInput := widget.NewEntry()
paramsInput := widget.NewEntry()
paramsInput.PlaceHolder = "多个数值使用,分隔"
this.form.AppendItem(widget.NewFormItem("任务类型", rtaskTypeInput))
this.form.AppendItem(widget.NewFormItem("参数", paramsInput))
this.form.OnSubmit = func() {
if rtaskTypeInput.Text == "" {
dialog.ShowError(errors.New("请填写任务类型ID"), this.w)
return
}
if paramsInput.Text == "" {
dialog.ShowError(errors.New("请填写任务条件参数"), this.w)
return
}
if err := service.GetPttService().SendToClient(
t.MainType,
t.SubType,
&pb.RtaskTestReq{RtaskType: cast.ToInt32(rtaskTypeInput.Text), Params: utils.TrInt32(paramsInput.Text)},
); err != nil {
logrus.Error(err)
return
}
}
return this.form
}

View File

@ -108,6 +108,8 @@ const (
TableGourmet = "gourmet"
// 随机任务
TableRtask = "rtask"
// 随机任务触发记录
TableRtaskRecord = "rrecord"
///爬塔排行
TablePagodaRank = "pagodarank"
/// 美食馆

View File

@ -0,0 +1,21 @@
package rtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode, data proto.Message) {
code = this.moduleRtask.SendToRtask(session, comm.TaskType(req.RtaskType), req.Params...)
if err := session.SendMsg(string(this.moduleRtask.GetType()), "rtasktest", &pb.RtaskTestResp{Flag: true}); err != nil {
code = pb.ErrorCode_SystemError
}
return
}

View File

@ -4,11 +4,7 @@ package rtask
import cfg "go_dreamfactory/sys/configure/structs"
// 与每个参数比较
func (this *ModelRtask) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
if len(vals) != 1 {
return
}
func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
var (
err error
paramLen int

View File

@ -0,0 +1,34 @@
package rtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"github.com/pkg/errors"
)
type ModelRtaskRecord struct {
modules.MCompModel
moduleRtask *ModuleRtask
service core.IService
}
func (this *ModelRtaskRecord) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableRtaskRecord
err = this.MCompModel.Init(service, module, comp, options)
this.moduleRtask = module.(*ModuleRtask)
this.service = service
return
}
// 获取玩家待校验数据
func (this *ModelRtaskRecord) GetVerifyData(uid string, condiId int32) (*pb.RtaskData, error) {
record := &pb.DBRtaskRecord{}
err := this.Get(uid, record)
if err != nil {
return nil, errors.Wrapf(err, "record Get err: %v condiId[%v]", uid, condiId)
}
return record.Vals[condiId], nil
}

View File

@ -93,6 +93,9 @@ func (this *ModelRtask) findAndUpdate(uid string, rtypeId comm.TaskType, vals ..
if int32(rtypeId) == v.cfg.Type {
if condiId = v.find(v.cfg, vals...); condiId == 0 {
continue
} else {
condi = v
break
}
}
}
@ -104,13 +107,3 @@ func (this *ModelRtask) findAndUpdate(uid string, rtypeId comm.TaskType, vals ..
return
}
// 获取玩家待校验数据
func (this *ModelRtask) GetVerifyData(uid string, condiId int32) (*pb.RtaskData, error) {
record := &pb.DBRtaskRecord{}
err := this.Get(uid, record)
if err != nil {
return nil, errors.Wrapf(err, "record Get err: %v condiId[%v]", uid, condiId)
}
return record.Vals[condiId], nil
}

View File

@ -24,9 +24,10 @@ type updateDataHandle func(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int
type ModuleRtask struct {
modules.ModuleBase
modelRtask *ModelRtask
api *apiComp
configure *configureComp
modelRtask *ModelRtask
modelRtaskRecord *ModelRtaskRecord
api *apiComp
configure *configureComp
handleMap map[int32]*rtaskCondi //任务校验处理器
}
@ -51,6 +52,7 @@ func (this *ModuleRtask) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelRtask = this.RegisterComp(new(ModelRtask)).(*ModelRtask)
this.modelRtaskRecord = this.RegisterComp(new(ModelRtaskRecord)).(*ModelRtaskRecord)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
@ -74,177 +76,177 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
case comm.Rtype1:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
verify: this.modelRtask.verify,
find: this.modelRtask.equalParams,
update: this.modelRtask.overrideUpdate,
verify: this.modelRtaskRecord.verify,
find: this.modelRtaskRecord.equalParams,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype2:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
verify: this.modelRtask.verify,
find: this.modelRtask.equalParams,
update: this.modelRtask.overrideUpdate,
verify: this.modelRtaskRecord.verify,
find: this.modelRtaskRecord.equalParams,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype3:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
verify: this.modelRtask.verify,
find: this.modelRtask.equalParams,
update: this.modelRtask.overrideUpdate,
verify: this.modelRtaskRecord.verify,
find: this.modelRtaskRecord.equalParams,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype4:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
verify: this.modelRtask.verify,
find: this.modelRtask.equalParams,
update: this.modelRtask.overrideUpdate,
verify: this.modelRtaskRecord.verify,
find: this.modelRtaskRecord.equalParams,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype5:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
verify: this.modelRtask.verify,
find: this.modelRtask.equalParams,
update: this.modelRtask.overrideUpdate,
verify: this.modelRtaskRecord.verify,
find: this.modelRtaskRecord.equalParams,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype6:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype7:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype8:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.addUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.addUpdate,
})
case comm.Rtype9:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype10:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype11:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype12:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype13:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype14:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype15:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype16:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype17:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype18:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype19:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype20:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype21:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype22:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype23:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype24:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
case comm.Rtype25:
this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg,
find: this.modelRtask.equalParams,
verify: this.modelRtask.verify,
update: this.modelRtask.overrideUpdate,
find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verify,
update: this.modelRtaskRecord.overrideUpdate,
})
default:
log.Warnf("%v rtask type not configure", typeCfg.Type)
@ -255,5 +257,8 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
}
func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
if err := this.modelRtask.findAndUpdate(session.GetUserId(), rtaskType, params...); err != nil {
code = pb.ErrorCode_DBError
}
return
}

View File

@ -6,19 +6,24 @@ import (
cfg "go_dreamfactory/sys/configure/structs"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
)
// 覆盖更新
func (this *ModelRtask) overrideUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
var paramLen int
if paramLen, err = verifyParam(cfg, vals...); err != nil {
return err
}
record := &pb.DBRtaskRecord{}
err = this.Get(uid, record)
if err != nil {
return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id)
if err2 := this.Get(uid, record); err2 != nil {
if err2 != mongo.ErrNoDocuments {
return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id)
} else {
err = err2
}
}
if record.Vals == nil {
@ -28,6 +33,10 @@ func (this *ModelRtask) overrideUpdate(uid string, cfg *cfg.GameRdtaskCondiData,
record.Vals = map[int32]*pb.RtaskData{
cfg.Id: data,
}
record.Id = primitive.NewObjectID().Hex()
record.Uid = uid
record.RType = cfg.Type
if err := this.Add(uid, record); err != nil {
return errors.Wrapf(err, "添加玩家任务记录 err: %v rtype[%v]", uid, cfg.Id)
}
@ -48,7 +57,7 @@ func (this *ModelRtask) overrideUpdate(uid string, cfg *cfg.GameRdtaskCondiData,
}
// 累计更新 - 招募等
func (this *ModelRtask) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
var paramLen int
if paramLen, err = verifyParam(cfg, vals...); err != nil {
return err

View File

@ -8,7 +8,7 @@ import (
"github.com/pkg/errors"
)
func (this *ModelRtask) verify(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
func (this *ModelRtaskRecord) verify(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
var rd *pb.RtaskData
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
if len(rd.Data) == 0 {

View File

@ -48,7 +48,7 @@ func TestVerify2(t *testing.T) {
defer patches.Reset()
//
rtask := &ModelRtask{}
rtask := &ModelRtaskRecord{}
conf := &cfg.GameRdtaskCondiData{
Id: 101,
Type: 1,
@ -57,6 +57,14 @@ func TestVerify2(t *testing.T) {
err, ok := rtask.verify("11", conf)
So(err, ShouldEqual, nil)
So(ok, ShouldEqual, true)
//模拟接口参数传入
patches3 := gomonkey.ApplyGlobalVar(&vals, []int32{25001})
defer patches3.Reset()
condiId := rtask.equalParams(conf, vals...)
So(condiId, ShouldEqual, 101)
})
})

View File

@ -105,6 +105,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
}
if this.module.modelUser.isLoginFirst(lastLoginTime) {
this.module.ModuleRtask.SendToRtask(session, comm.Rtype7, 1)
//清空日常
this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_DAILY)
//清周常

View File

@ -3,9 +3,10 @@ package user
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/mongo"
)
// 记录一些扩展数据
@ -34,7 +35,7 @@ func (this *ModelExpand) getUserSession(uid string) (cuser *pb.CacheUser) {
//获取用户通过扩展表
func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
result = &pb.DBUserExpand{}
if err = this.module.modelExpand.Get(uid, result); err != nil && redis.RedisNil != err {
if err = this.module.modelExpand.Get(uid, result); err != nil && mongo.ErrNoDocuments != err {
return
}
err = nil

View File

@ -504,6 +504,109 @@ func (x *RtaskGetRewardResp) GetRtaskSubId() int32 {
return 0
}
// 测试使用
type RtaskTestReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RtaskType int32 `protobuf:"varint,1,opt,name=rtaskType,proto3" json:"rtaskType"` //任务类型
Params []int32 `protobuf:"varint,2,rep,packed,name=params,proto3" json:"params"` //参数
}
func (x *RtaskTestReq) Reset() {
*x = RtaskTestReq{}
if protoimpl.UnsafeEnabled {
mi := &file_rtask_rtask_msg_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RtaskTestReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RtaskTestReq) ProtoMessage() {}
func (x *RtaskTestReq) ProtoReflect() protoreflect.Message {
mi := &file_rtask_rtask_msg_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RtaskTestReq.ProtoReflect.Descriptor instead.
func (*RtaskTestReq) Descriptor() ([]byte, []int) {
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{9}
}
func (x *RtaskTestReq) GetRtaskType() int32 {
if x != nil {
return x.RtaskType
}
return 0
}
func (x *RtaskTestReq) GetParams() []int32 {
if x != nil {
return x.Params
}
return nil
}
type RtaskTestResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Flag bool `protobuf:"varint,1,opt,name=flag,proto3" json:"flag"`
}
func (x *RtaskTestResp) Reset() {
*x = RtaskTestResp{}
if protoimpl.UnsafeEnabled {
mi := &file_rtask_rtask_msg_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RtaskTestResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RtaskTestResp) ProtoMessage() {}
func (x *RtaskTestResp) ProtoReflect() protoreflect.Message {
mi := &file_rtask_rtask_msg_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RtaskTestResp.ProtoReflect.Descriptor instead.
func (*RtaskTestResp) Descriptor() ([]byte, []int) {
return file_rtask_rtask_msg_proto_rawDescGZIP(), []int{10}
}
func (x *RtaskTestResp) GetFlag() bool {
if x != nil {
return x.Flag
}
return false
}
var File_rtask_rtask_msg_proto protoreflect.FileDescriptor
var file_rtask_rtask_msg_proto_rawDesc = []byte{
@ -547,8 +650,14 @@ var file_rtask_rtask_msg_proto_rawDesc = []byte{
0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x74, 0x61, 0x73, 0x6b,
0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x75, 0x62, 0x49, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x75, 0x62,
0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x49, 0x64, 0x22, 0x44, 0x0a, 0x0c, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x65, 0x73, 0x74, 0x52,
0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05,
0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x23, 0x0a, 0x0d, 0x52, 0x74, 0x61, 0x73,
0x6b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x6c, 0x61,
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -563,7 +672,7 @@ func file_rtask_rtask_msg_proto_rawDescGZIP() []byte {
return file_rtask_rtask_msg_proto_rawDescData
}
var file_rtask_rtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_rtask_rtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_rtask_rtask_msg_proto_goTypes = []interface{}{
(*RtaskApplyReq)(nil), // 0: RtaskApplyReq
(*RtaskApplyResp)(nil), // 1: RtaskApplyResp
@ -574,6 +683,8 @@ var file_rtask_rtask_msg_proto_goTypes = []interface{}{
(*RtaskFinishPush)(nil), // 6: RtaskFinishPush
(*RtaskGetRewardReq)(nil), // 7: RtaskGetRewardReq
(*RtaskGetRewardResp)(nil), // 8: RtaskGetRewardResp
(*RtaskTestReq)(nil), // 9: RtaskTestReq
(*RtaskTestResp)(nil), // 10: RtaskTestResp
}
var file_rtask_rtask_msg_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -697,6 +808,30 @@ func file_rtask_rtask_msg_proto_init() {
return nil
}
}
file_rtask_rtask_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RtaskTestReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rtask_rtask_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RtaskTestResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -704,7 +839,7 @@ func file_rtask_rtask_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_rtask_rtask_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumMessages: 11,
NumExtensions: 0,
NumServices: 0,
},