铁匠图
This commit is contained in:
parent
992237568f
commit
3102a7729f
@ -140,7 +140,7 @@ const (
|
||||
|
||||
TableSeasonRecord = "seasonRecord" // 赛季塔记录
|
||||
/// 美食馆
|
||||
TableSmithy = "smithy"
|
||||
TableSmithy = "smithy"
|
||||
TableSmithyTrade = "trade"
|
||||
/// 赛季塔数据表
|
||||
TableSeasonPagoda = "seasonpagoda"
|
||||
@ -222,6 +222,9 @@ const (
|
||||
|
||||
// pvp
|
||||
TablePvp = "pvp"
|
||||
|
||||
// 铁匠铺铸造台
|
||||
TableStove = "stove"
|
||||
)
|
||||
|
||||
// RPC服务接口定义处
|
||||
|
@ -24,7 +24,7 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
stove, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||
stove, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -20,7 +20,7 @@ func (this *apiComp) GetStoveInfo(session comm.IUserSession, req *pb.SmithyGetSt
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
_smithy, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||
_smithy, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -24,7 +24,7 @@ func (this *apiComp) OrderEquip(session comm.IUserSession, req *pb.SmithyOrderEq
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
stove, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||
stove, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -23,7 +23,7 @@ func (this *apiComp) Rise(session comm.IUserSession, req *pb.SmithyRiseReq) (cod
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
stove, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||
stove, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -8,18 +8,18 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) StrveUpCheck(session comm.IUserSession, req *pb.SmithyStoveUpReq) (code pb.ErrorCode) {
|
||||
func (this *apiComp) StoveUpCheck(session comm.IUserSession, req *pb.SmithyStoveUpReq) (code pb.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 炉子升级
|
||||
func (this *apiComp) StrveUp(session comm.IUserSession, req *pb.SmithyStoveUpReq) (code pb.ErrorCode, data proto.Message) {
|
||||
code = this.StrveUpCheck(session, req)
|
||||
func (this *apiComp) StoveUp(session comm.IUserSession, req *pb.SmithyStoveUpReq) (code pb.ErrorCode, data proto.Message) {
|
||||
code = this.StoveUpCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
stove, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||
stove, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -19,7 +19,7 @@ func (this *apiComp) ToolsUp(session comm.IUserSession, req *pb.SmithyToolsUpReq
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
stove, err := this.module.modelSmithy.getSmithyStoveList(session.GetUserId())
|
||||
stove, err := this.module.modelStove.getSmithyStoveList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -186,33 +186,3 @@ func (this *modelSmithy) CalculationStoveSkillLv(uid string, Smithy *pb.DBSmithy
|
||||
mapData["orderCostTime"] = Smithy.OrderCostTime
|
||||
this.module.ModifySmithyData(uid, mapData)
|
||||
}
|
||||
|
||||
// 获取铁匠铺信息
|
||||
func (this *modelSmithy) getSmithyStoveList(uid string) (result *pb.DBStove, err error) {
|
||||
result = &pb.DBStove{}
|
||||
if err = this.Get(uid, result); err != nil {
|
||||
if redis.RedisNil != err { // 没有数据直接创建新的数据
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
result.Uid = uid
|
||||
result.Data = make(map[int32]int32, 0)
|
||||
result.Skill = make(map[int32]int32, 0)
|
||||
result.Lv = 1
|
||||
result.Temperature = 20000 // 配置
|
||||
result.RecoveTime = 0
|
||||
|
||||
if err = this.Add(uid, result); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (this *modelSmithy) updateSmithyStove(uid string, update map[string]interface{}) (err error) {
|
||||
err = this.Change(uid, update)
|
||||
return err
|
||||
}
|
||||
|
60
modules/smithy/model_stove.go
Normal file
60
modules/smithy/model_stove.go
Normal file
@ -0,0 +1,60 @@
|
||||
package smithy
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||
)
|
||||
|
||||
type modelStove struct {
|
||||
modules.MCompModel
|
||||
module *Smithy
|
||||
}
|
||||
|
||||
func (this *modelStove) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = string(comm.TableStove)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.module = module.(*Smithy)
|
||||
// uid 创建索引
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取铁匠铺信息
|
||||
func (this *modelStove) getSmithyStoveList(uid string) (result *pb.DBStove, err error) {
|
||||
result = &pb.DBStove{}
|
||||
if err = this.Get(uid, result); err != nil {
|
||||
if redis.RedisNil != err { // 没有数据直接创建新的数据
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
result.Uid = uid
|
||||
result.Data = make(map[int32]int32, 0)
|
||||
result.Skill = make(map[int32]int32, 0)
|
||||
result.Forge = make(map[int32]int32, 0)
|
||||
result.Lv = 1
|
||||
result.Temperature = 20000 // 配置
|
||||
result.RecoveTime = 0
|
||||
|
||||
if err = this.Add(uid, result); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (this *modelStove) updateSmithyStove(uid string, update map[string]interface{}) (err error) {
|
||||
err = this.Change(uid, update)
|
||||
return err
|
||||
}
|
@ -18,6 +18,7 @@ type Smithy struct {
|
||||
modelTrade *modelTrade
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
modelStove *modelStove
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -40,6 +41,7 @@ func (this *Smithy) OnInstallComp() {
|
||||
this.modelSmithy = this.RegisterComp(new(modelSmithy)).(*modelSmithy)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
this.modelTrade = this.RegisterComp(new(modelTrade)).(*modelTrade)
|
||||
this.modelStove = this.RegisterComp(new(modelStove)).(*modelStove)
|
||||
}
|
||||
|
||||
// 接口信息
|
||||
|
Loading…
Reference in New Issue
Block a user