提供对外接口 用来修改主线关卡信息
This commit is contained in:
parent
469f2274c6
commit
62eec8a69a
@ -69,4 +69,7 @@ type (
|
||||
//添加新武器
|
||||
AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode)
|
||||
}
|
||||
IStory interface {
|
||||
ModifyStoryData(uid string, objid string, data interface{}) (code pb.ErrorCode)
|
||||
}
|
||||
)
|
||||
|
@ -8,18 +8,28 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.StoryGetListReq) (code pb.ErrorCode) {
|
||||
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.StoryGetListReq) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
///获取用户道具
|
||||
func (this *apiComp) Getlist(session comm.IUserSession, req *pb.StoryGetListReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
///获取主线关卡信息
|
||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.StoryGetListReq) (code pb.ErrorCode, data proto.Message) {
|
||||
rsp := &pb.StoryGetListResp{}
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), StoryGetListResp, &pb.StoryGetListResp{})
|
||||
session.SendMsg(string(this.module.GetType()), StoryGetListResp, &pb.StoryGetListResp{Data: rsp.Data})
|
||||
|
||||
}()
|
||||
code = this.GetListCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
list, err := this.module.modelStory.getStoryList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
rsp.Data = list
|
||||
return
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package story
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
@ -11,10 +12,27 @@ const ( //Redis
|
||||
|
||||
type ModelStory struct {
|
||||
modules.MCompModel
|
||||
moduleStory *Story
|
||||
}
|
||||
|
||||
func (this *ModelStory) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.moduleStory = module.(*Story)
|
||||
this.TableName = string(TableStory)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取章节信息
|
||||
func (this *ModelStory) getStoryList(uid string) ([]*pb.DBStory, error) {
|
||||
storys := make([]*pb.DBStory, 0)
|
||||
err := this.GetList(uid, &storys)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return storys, nil
|
||||
}
|
||||
|
||||
// 修改章节信息
|
||||
func (this *ModelStory) modifyStoryData(uid string, objid string, data map[string]interface{}) error {
|
||||
return this.moduleStory.modelStory.ChangeList(uid, objid, data)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type Story struct {
|
||||
@ -31,3 +32,12 @@ func (this *Story) OnInstallComp() {
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelStory = this.RegisterComp(new(ModelStory)).(*ModelStory)
|
||||
}
|
||||
|
||||
// 接口信息 给其他模块调用 用来修改主线关卡信息
|
||||
func (this *Story) ModifyStoryData(uid string, objid string, data map[string]interface{}) (code pb.ErrorCode) {
|
||||
err := this.modelStory.modifyStoryData(uid, objid, data)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
|
||||
message DBStory {
|
||||
string id = 1; //@go_tags(`bson:"_id"`) ID
|
||||
string uid = 2; //@go_tags(`bson:"uid"`) 用户ID
|
||||
string uuid = 3; //@go_tags(`bson:"uuid"`) 玩家唯一uuid
|
||||
int32 storyId = 4; //@go_tags(`bson:"storyId"`) 主线关卡ID
|
||||
int32 intensity = 5; //@go_tags(`bson:"intensity"`) 难度类型
|
||||
int32 awaredID = 6; //@go_tags(`bson:"awaredID"`) 领奖ID
|
||||
int32 progress = 7; // @go_tags(`bson:"progress"`) 通关进度
|
||||
string id = 1; //@go_tags(`bson:"_id"`) ID
|
||||
string uid = 2; //@go_tags(`bson:"uid"`) 用户ID
|
||||
int32 chapterId = 3; //@go_tags(`bson:"chapterId"`) 章节ID
|
||||
int32 storyId = 4; //@go_tags(`bson:"storyId"`) 主线关卡ID
|
||||
int32 intensity = 5; //@go_tags(`bson:"intensity"`) 难度类型
|
||||
int32 awaredID = 6; //@go_tags(`bson:"awaredID"`) 领奖ID
|
||||
int32 progress = 7; // @go_tags(`bson:"progress"`) 通关进度
|
||||
}
|
@ -7,4 +7,6 @@ message StoryGetListReq {
|
||||
|
||||
}
|
||||
// 返回进度信息
|
||||
message StoryGetListResp { DBStory data = 1; }
|
||||
message StoryGetListResp {
|
||||
repeated DBStory data = 1;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ type DBStory struct {
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
|
||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
|
||||
Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid" bson:"uuid"` //玩家唯一uuid
|
||||
ChapterId int32 `protobuf:"varint,3,opt,name=chapterId,proto3" json:"chapterId" bson:"chapterId"` //章节ID
|
||||
StoryId int32 `protobuf:"varint,4,opt,name=storyId,proto3" json:"storyId" bson:"storyId"` //主线关卡ID
|
||||
Intensity int32 `protobuf:"varint,5,opt,name=intensity,proto3" json:"intensity" bson:"intensity"` //难度类型
|
||||
AwaredID int32 `protobuf:"varint,6,opt,name=awaredID,proto3" json:"awaredID" bson:"awaredID"` //领奖ID
|
||||
@ -80,11 +80,11 @@ func (x *DBStory) GetUid() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DBStory) GetUuid() string {
|
||||
func (x *DBStory) GetChapterId() int32 {
|
||||
if x != nil {
|
||||
return x.Uuid
|
||||
return x.ChapterId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBStory) GetStoryId() int32 {
|
||||
@ -119,19 +119,20 @@ var File_story_story_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_story_story_db_proto_rawDesc = []byte{
|
||||
0x0a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x64, 0x62,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaf, 0x01, 0x0a, 0x07, 0x44, 0x42, 0x53, 0x74, 0x6f,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x01, 0x0a, 0x07, 0x44, 0x42, 0x53, 0x74, 0x6f,
|
||||
0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
|
||||
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72,
|
||||
0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79,
|
||||
0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x18,
|
||||
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79,
|
||||
0x12, 0x1a, 0x0a, 0x08, 0x61, 0x77, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x08, 0x61, 0x77, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
|
||||
0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x49,
|
||||
0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72,
|
||||
0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x77,
|
||||
0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x77,
|
||||
0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65,
|
||||
0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65,
|
||||
0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -65,7 +65,7 @@ type StoryGetListResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Data *DBStory `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
|
||||
Data []*DBStory `protobuf:"bytes,1,rep,name=data,proto3" json:"data"`
|
||||
}
|
||||
|
||||
func (x *StoryGetListResp) Reset() {
|
||||
@ -100,7 +100,7 @@ func (*StoryGetListResp) Descriptor() ([]byte, []int) {
|
||||
return file_story_story_msg_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *StoryGetListResp) GetData() *DBStory {
|
||||
func (x *StoryGetListResp) GetData() []*DBStory {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
@ -115,7 +115,7 @@ var file_story_story_msg_proto_rawDesc = []byte{
|
||||
0x74, 0x6f, 0x72, 0x79, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x11, 0x0a,
|
||||
0x0f, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71,
|
||||
0x22, 0x30, 0x0a, 0x10, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
|
||||
0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x08, 0x2e, 0x44, 0x42, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61,
|
||||
0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
|
Loading…
Reference in New Issue
Block a user