数据校验
This commit is contained in:
parent
cfc9a018f0
commit
e40621b335
@ -23,7 +23,7 @@ var (
|
|||||||
fmt.Printf("%d- %v\n", (i + 1), v)
|
fmt.Printf("%d- %v\n", (i + 1), v)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: true,
|
//enabled: true,
|
||||||
}, {
|
}, {
|
||||||
desc: "主线详情",
|
desc: "主线详情",
|
||||||
mainType: string(comm.ModuleStory),
|
mainType: string(comm.ModuleStory),
|
||||||
@ -33,7 +33,7 @@ var (
|
|||||||
StoryId: 1,
|
StoryId: 1,
|
||||||
},
|
},
|
||||||
rsp: &pb.StoryChallengeResp{},
|
rsp: &pb.StoryChallengeResp{},
|
||||||
// enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -99,13 +99,15 @@ func (this *ServiceBase) Run(mod ...core.IModule) {
|
|||||||
mi: v,
|
mi: v,
|
||||||
closeSig: make(chan bool, 1),
|
closeSig: make(chan bool, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Warnf("注册模块【%s】 对应的配置信息", v.GetType())
|
||||||
} else {
|
} else {
|
||||||
this.modules[v.GetType()] = &defaultModule{
|
this.modules[v.GetType()] = &defaultModule{
|
||||||
seetring: make(map[string]interface{}),
|
seetring: make(map[string]interface{}),
|
||||||
mi: v,
|
mi: v,
|
||||||
closeSig: make(chan bool, 1),
|
closeSig: make(chan bool, 1),
|
||||||
}
|
}
|
||||||
log.Warnf("注册模块【%s】 没有对应的配置信息", v.GetType())
|
//log.Warnf("注册模块【%s】 没有对应的配置信息", v.GetType())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, v := range this.modules { //序列化每一个模块的参数对象 完成模块的初始化 过程
|
for _, v := range this.modules { //序列化每一个模块的参数对象 完成模块的初始化 过程
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,20 +40,35 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge
|
|||||||
if len(list) > 0 {
|
if len(list) > 0 {
|
||||||
curChapter = list[0] // 取第一条(第一条肯定是最新的)
|
curChapter = list[0] // 取第一条(第一条肯定是最新的)
|
||||||
}
|
}
|
||||||
if curChapter == nil {
|
|
||||||
code = pb.ErrorCode_StoryNotFindChapter // 没有找到主线关卡信息
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 先校验是不是分支
|
// 先校验是不是分支
|
||||||
chaptConfig := this.module.configure.GetStoryChapter(int32(req.ChapterId)) // 根据配置文件找
|
chaptConfig := this.module.configure.GetStoryChapter(int32(req.ChapterId)) // 根据配置文件找
|
||||||
if chaptConfig == nil {
|
if chaptConfig == nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if curChapter == nil {
|
||||||
|
if len(chaptConfig.Fubendata) <= 0 {
|
||||||
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if int32(req.ChapterId) != 1 {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_data := &pb.DBStory{}
|
||||||
|
_data.Id = primitive.NewObjectID().Hex()
|
||||||
|
_data.ChapterId = int32(req.ChapterId)
|
||||||
|
_map := make(map[string]*pb.DBStory)
|
||||||
|
_map[_data.Id] = _data
|
||||||
|
//this.module.modelStory.addNewChapter(session.GetUserId(), _map)
|
||||||
|
curChapter = _data
|
||||||
|
//curChapter.StoryId = chaptConfig.Fubendata[0] // 第一次挑战
|
||||||
|
}
|
||||||
// 根据难度找对应的配置文件
|
// 根据难度找对应的配置文件
|
||||||
if chaptConfig.Intensity == "1" { // 这里安临时配置读取 后面会修改
|
if chaptConfig.Intensity == "1" { // 这里按临时配置读取 后面会修改
|
||||||
con := this.module.configure.GetStoryEasyChapter(int32(req.StoryId)) // 根据配置文件找
|
con := this.module.configure.GetStoryEasyChapter(int32(req.StoryId)) // 根据配置文件找
|
||||||
if con != nil {
|
if con == nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -66,6 +82,8 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.StoryChallenge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO 调用战斗逻辑
|
// TODO 调用战斗逻辑
|
||||||
|
// 挑战成功
|
||||||
|
curChapter.StoryId += 1 // 临时数据 后面配置表完善查找
|
||||||
if bBranch {
|
if bBranch {
|
||||||
curChapter.BranchID = append(curChapter.BranchID, int32(req.ChapterId)) // 记录分支关卡
|
curChapter.BranchID = append(curChapter.BranchID, int32(req.ChapterId)) // 记录分支关卡
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package story
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
@ -33,3 +34,13 @@ func (this *ModelStory) getStoryList(uid string) (storys []*pb.DBStory, err erro
|
|||||||
func (this *ModelStory) modifyStoryData(uid string, objid string, data map[string]interface{}) error {
|
func (this *ModelStory) modifyStoryData(uid string, objid string, data map[string]interface{}) error {
|
||||||
return this.moduleStory.modelStory.ChangeList(uid, objid, data)
|
return this.moduleStory.modelStory.ChangeList(uid, objid, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增加新的章节数据
|
||||||
|
func (this *ModelStory) addNewChapter(uId string, data map[string]interface{}) (err error) {
|
||||||
|
|
||||||
|
if err = this.AddLists(uId, data); err != nil {
|
||||||
|
log.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode) {
|
func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode) {
|
||||||
if req.Res.A == "" || req.Res.T == "" || req.Res.N > 0 {
|
if req.Res.A == "" || req.Res.T == "" || req.Res.N <= 0 {
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user