提供对外接口 用来修改主线关卡信息

This commit is contained in:
meixiongfeng 2022-07-05 19:24:00 +08:00
parent 469f2274c6
commit 62eec8a69a
8 changed files with 75 additions and 31 deletions

View File

@ -69,4 +69,7 @@ type (
//添加新武器 //添加新武器
AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode)
} }
IStory interface {
ModifyStoryData(uid string, objid string, data interface{}) (code pb.ErrorCode)
}
) )

View File

@ -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 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() { 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 return
} }

View File

@ -3,6 +3,7 @@ package story
import ( import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb"
) )
const ( //Redis const ( //Redis
@ -11,10 +12,27 @@ const ( //Redis
type ModelStory struct { type ModelStory struct {
modules.MCompModel modules.MCompModel
moduleStory *Story
} }
func (this *ModelStory) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { 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) err = this.MCompModel.Init(service, module, comp, options)
this.moduleStory = module.(*Story)
this.TableName = string(TableStory) this.TableName = string(TableStory)
return 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)
}

View File

@ -4,6 +4,7 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb"
) )
type Story struct { type Story struct {
@ -31,3 +32,12 @@ func (this *Story) OnInstallComp() {
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelStory = this.RegisterComp(new(ModelStory)).(*ModelStory) 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
}

View File

@ -4,7 +4,7 @@ option go_package = ".;pb";
message DBStory { message DBStory {
string id = 1; //@go_tags(`bson:"_id"`) ID string id = 1; //@go_tags(`bson:"_id"`) ID
string uid = 2; //@go_tags(`bson:"uid"`) ID string uid = 2; //@go_tags(`bson:"uid"`) ID
string uuid = 3; //@go_tags(`bson:"uuid"`) uuid int32 chapterId = 3; //@go_tags(`bson:"chapterId"`) ID
int32 storyId = 4; //@go_tags(`bson:"storyId"`) 线ID int32 storyId = 4; //@go_tags(`bson:"storyId"`) 线ID
int32 intensity = 5; //@go_tags(`bson:"intensity"`) int32 intensity = 5; //@go_tags(`bson:"intensity"`)
int32 awaredID = 6; //@go_tags(`bson:"awaredID"`) ID int32 awaredID = 6; //@go_tags(`bson:"awaredID"`) ID

View File

@ -7,4 +7,6 @@ message StoryGetListReq {
} }
// //
message StoryGetListResp { DBStory data = 1; } message StoryGetListResp {
repeated DBStory data = 1;
}

View File

@ -27,7 +27,7 @@ type DBStory struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID 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 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 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"` //难度类型 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 AwaredID int32 `protobuf:"varint,6,opt,name=awaredID,proto3" json:"awaredID" bson:"awaredID"` //领奖ID
@ -80,11 +80,11 @@ func (x *DBStory) GetUid() string {
return "" return ""
} }
func (x *DBStory) GetUuid() string { func (x *DBStory) GetChapterId() int32 {
if x != nil { if x != nil {
return x.Uuid return x.ChapterId
} }
return "" return 0
} }
func (x *DBStory) GetStoryId() int32 { 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{ var file_story_story_db_proto_rawDesc = []byte{
0x0a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x64, 0x62, 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, 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, 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, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x49,
0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72,
0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20,
0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x18, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09,
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
0x12, 0x1a, 0x0a, 0x08, 0x61, 0x77, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x77,
0x28, 0x05, 0x52, 0x08, 0x61, 0x77, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x77,
0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x72, 0x65, 0x64, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65,
0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
} }
var ( var (

View File

@ -65,7 +65,7 @@ type StoryGetListResp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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() { func (x *StoryGetListResp) Reset() {
@ -100,7 +100,7 @@ func (*StoryGetListResp) Descriptor() ([]byte, []int) {
return file_story_story_msg_proto_rawDescGZIP(), []int{1} return file_story_story_msg_proto_rawDescGZIP(), []int{1}
} }
func (x *StoryGetListResp) GetData() *DBStory { func (x *StoryGetListResp) GetData() []*DBStory {
if x != nil { if x != nil {
return x.Data 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, 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, 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, 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, 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, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33, 0x6f, 0x33,