藏书馆
This commit is contained in:
parent
14c474cc0b
commit
900910e101
@ -60,6 +60,7 @@ const (
|
||||
ModuleHunting core.M_Modules = "hunting" //狩猎
|
||||
ModuleLinestory core.M_Modules = "linestory" //支线剧情
|
||||
ModuleBattle core.M_Modules = "battle" //战斗
|
||||
ModuleLibrary core.M_Modules = "library" //
|
||||
)
|
||||
|
||||
//数据表名定义处
|
||||
@ -133,6 +134,8 @@ const (
|
||||
|
||||
// 支线剧情任务
|
||||
TableLinestory = "linestory"
|
||||
|
||||
TableLibrary = "library"
|
||||
)
|
||||
|
||||
//RPC服务接口定义处
|
||||
|
31
modules/library/api_getlist.go
Normal file
31
modules/library/api_getlist.go
Normal file
@ -0,0 +1,31 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.DBHero) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.DBHero) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
code = this.GetListCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
// list, err := this.module.modelLibrary.getLibraryList(session.GetUserId())
|
||||
// if err != nil {
|
||||
// code = pb.ErrorCode_DBError
|
||||
// return
|
||||
// }
|
||||
|
||||
//session.SendMsg(string(this.module.GetType()), LibraryGetListResp, &pb.LibraryGetListResp{Data: list})
|
||||
return
|
||||
}
|
44
modules/library/model_hunting.go
Normal file
44
modules/library/model_hunting.go
Normal file
@ -0,0 +1,44 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||
)
|
||||
|
||||
type modelLibrary struct {
|
||||
modules.MCompModel
|
||||
module *Library
|
||||
}
|
||||
|
||||
func (this *modelLibrary) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = string(comm.TableLibrary)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.module = module.(*Library)
|
||||
// uid 创建索引
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelLibrary) modifyLibraryDataByObjId(uid string, data map[string]interface{}) error {
|
||||
return this.Change(uid, data)
|
||||
}
|
||||
|
||||
// 获取列表信息
|
||||
func (this *modelLibrary) getLibraryList(uid string) (result *pb.DBHero, err error) {
|
||||
result = &pb.DBHero{}
|
||||
if err = this.Get(uid, result); err != nil && mgo.MongodbNil != err {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
err = nil
|
||||
return result, err
|
||||
}
|
46
modules/library/module.go
Normal file
46
modules/library/module.go
Normal file
@ -0,0 +1,46 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type Library struct {
|
||||
modules.ModuleBase
|
||||
modelLibrary *modelLibrary
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
return &Library{}
|
||||
}
|
||||
|
||||
func (this *Library) GetType() core.M_Modules {
|
||||
return comm.ModuleLibrary
|
||||
}
|
||||
|
||||
func (this *Library) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Library) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelLibrary = this.RegisterComp(new(modelLibrary)).(*modelLibrary)
|
||||
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
// 接口信息
|
||||
func (this *Library) ModifyLibraryData(uid string, data map[string]interface{}) (code pb.ErrorCode) {
|
||||
err := this.modelLibrary.modifyLibraryDataByObjId(uid, data)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user