diff --git a/comm/imodule.go b/comm/imodule.go index b3406456f..afea3c954 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -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) + } ) diff --git a/modules/story/api_getlist.go b/modules/story/api_getlist.go index c254c21a6..e4a30ae51 100644 --- a/modules/story/api_getlist.go +++ b/modules/story/api_getlist.go @@ -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 } diff --git a/modules/story/model_story.go b/modules/story/model_story.go index d58d51abc..98d05aa26 100644 --- a/modules/story/model_story.go +++ b/modules/story/model_story.go @@ -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) +} diff --git a/modules/story/module.go b/modules/story/module.go index 92dea3960..a4fd3f47e 100644 --- a/modules/story/module.go +++ b/modules/story/module.go @@ -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 +} diff --git a/pb/proto/story/story_db.proto b/pb/proto/story/story_db.proto index c9688ce4a..bb86041b0 100644 --- a/pb/proto/story/story_db.proto +++ b/pb/proto/story/story_db.proto @@ -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"`) 通关进度 } \ No newline at end of file diff --git a/pb/proto/story/story_msg.proto b/pb/proto/story/story_msg.proto index 5a23c489d..15068fa06 100644 --- a/pb/proto/story/story_msg.proto +++ b/pb/proto/story/story_msg.proto @@ -7,4 +7,6 @@ message StoryGetListReq { } // 返回进度信息 -message StoryGetListResp { DBStory data = 1; } +message StoryGetListResp { + repeated DBStory data = 1; +} diff --git a/pb/story_db.pb.go b/pb/story_db.pb.go index 89e834e77..f52479363 100644 --- a/pb/story_db.pb.go +++ b/pb/story_db.pb.go @@ -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 ( diff --git a/pb/story_msg.pb.go b/pb/story_msg.pb.go index 83c4885fc..699cad87d 100644 --- a/pb/story_msg.pb.go +++ b/pb/story_msg.pb.go @@ -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,