用户扩展数据图鉴数据保存
This commit is contained in:
parent
5b9b73f76b
commit
1670917a59
10
cmd/cmd.go
10
cmd/cmd.go
@ -3,10 +3,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/cmd/robot"
|
"go_dreamfactory/cmd/robot"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -38,8 +40,14 @@ var sid = flag.Int32("sid", 0, "区服ID")
|
|||||||
var create = flag.Bool("create", false, "是否创建新账号") //false 不创建新账号
|
var create = flag.Bool("create", false, "是否创建新账号") //false 不创建新账号
|
||||||
var role = flag.Bool("role", false, "创角")
|
var role = flag.Bool("role", false, "创角")
|
||||||
|
|
||||||
|
func CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) {
|
||||||
|
newHero = &*hero
|
||||||
|
newHero.Id = primitive.NewObjectID().Hex()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
func main() {
|
func main() {
|
||||||
Execute()
|
//Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
var runCmd = &cobra.Command{
|
var runCmd = &cobra.Command{
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes"
|
"github.com/golang/protobuf/ptypes"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
var service core.IService
|
var service core.IService
|
||||||
@ -55,8 +56,19 @@ func (this *TestService) InitSys() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
sz := GetMap()
|
||||||
|
if len(sz) == 0 {
|
||||||
|
sz = make(map[int32]int32, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
sz[2] = 2
|
||||||
|
hero := &pb.DBHero{}
|
||||||
|
hero.Block = false
|
||||||
|
hero.Lv = 12
|
||||||
|
new := CloneNewHero(hero)
|
||||||
|
fmt.Printf("%v", new)
|
||||||
service = newService(
|
service = newService(
|
||||||
rpcx.SetConfPath("../../bin/conf/worker_2.yaml"),
|
rpcx.SetConfPath("../../bin/conf/worker_1.yaml"),
|
||||||
)
|
)
|
||||||
service.OnInstallComp( //装备组件
|
service.OnInstallComp( //装备组件
|
||||||
s_gateComp, //此服务需要接受用户的消息 需要装备网关组件
|
s_gateComp, //此服务需要接受用户的消息 需要装备网关组件
|
||||||
@ -73,7 +85,20 @@ func TestMain(m *testing.M) {
|
|||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Second * 2)
|
||||||
defer os.Exit(m.Run())
|
defer os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetMap() map[int32]int32 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) {
|
||||||
|
temp := *hero
|
||||||
|
newHero = &temp
|
||||||
|
newHero.Block = true
|
||||||
|
newHero.Lv = 100
|
||||||
|
newHero.Id = primitive.NewObjectID().Hex()
|
||||||
|
return
|
||||||
|
}
|
||||||
func Test_Modules(t *testing.T) {
|
func Test_Modules(t *testing.T) {
|
||||||
|
|
||||||
data, _ := ptypes.MarshalAny(&pb.HeroListReq{})
|
data, _ := ptypes.MarshalAny(&pb.HeroListReq{})
|
||||||
reply := &pb.RPCMessageReply{}
|
reply := &pb.RPCMessageReply{}
|
||||||
s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{UserId: "0_62c79d66acc7aa239b07c21e", MainType: "hero", SubType: "list", Message: data}, reply)
|
s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{UserId: "0_62c79d66acc7aa239b07c21e", MainType: "hero", SubType: "list", Message: data}, reply)
|
||||||
|
@ -102,7 +102,8 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId string) (hero *pb.DBH
|
|||||||
|
|
||||||
// 克隆一个英雄
|
// 克隆一个英雄
|
||||||
func (this *ModelHero) CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) {
|
func (this *ModelHero) CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) {
|
||||||
newHero = &*hero
|
temp := *hero
|
||||||
|
newHero = &temp
|
||||||
newHero.Id = primitive.NewObjectID().Hex()
|
newHero.Id = primitive.NewObjectID().Hex()
|
||||||
this.AddList(newHero.Uid, newHero.Id, newHero)
|
this.AddList(newHero.Uid, newHero.Id, newHero)
|
||||||
return
|
return
|
||||||
@ -115,11 +116,12 @@ func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int
|
|||||||
// 添加图鉴
|
// 添加图鉴
|
||||||
go func(uid, heroCfgId string) { // 携程处理 图鉴数据
|
go func(uid, heroCfgId string) { // 携程处理 图鉴数据
|
||||||
if result, err1 := this.moduleHero.ModuleUser.GetUserExpand(uid); err1 == nil {
|
if result, err1 := this.moduleHero.ModuleUser.GetUserExpand(uid); err1 == nil {
|
||||||
sz := make(map[string]bool, 0)
|
|
||||||
for k := range result.GetTujian() {
|
|
||||||
sz[k] = true
|
|
||||||
}
|
|
||||||
if _, ok := result.GetTujian()[heroCfgId]; !ok {
|
if _, ok := result.GetTujian()[heroCfgId]; !ok {
|
||||||
|
sz := result.GetTujian()
|
||||||
|
if len(sz) == 0 {
|
||||||
|
sz = make(map[string]bool, 0)
|
||||||
|
}
|
||||||
sz[heroCfgId] = true
|
sz[heroCfgId] = true
|
||||||
initUpdate := map[string]interface{}{
|
initUpdate := map[string]interface{}{
|
||||||
"tujian": sz,
|
"tujian": sz,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
"go_dreamfactory/lego/sys/redis"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"time"
|
"time"
|
||||||
@ -33,9 +34,10 @@ func (this *ModelRecord) getUserSession(uid string) (cuser *pb.CacheUser) {
|
|||||||
//获取用户通过扩展表
|
//获取用户通过扩展表
|
||||||
func (this *ModelRecord) GetHeroRecord(uid string) (result *pb.DBHeroRecord, err error) {
|
func (this *ModelRecord) GetHeroRecord(uid string) (result *pb.DBHeroRecord, err error) {
|
||||||
result = &pb.DBHeroRecord{}
|
result = &pb.DBHeroRecord{}
|
||||||
if err = this.Get(uid, result); err != nil {
|
if err = this.Get(uid, result); err != nil && err != redis.RedisNil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = nil
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
"go_dreamfactory/lego/sys/redis"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
@ -34,10 +35,10 @@ func (this *ModelExpand) getUserSession(uid string) (cuser *pb.CacheUser) {
|
|||||||
//获取用户通过扩展表
|
//获取用户通过扩展表
|
||||||
func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
|
func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
|
||||||
result = &pb.DBUserExpand{}
|
result = &pb.DBUserExpand{}
|
||||||
if err = this.moduleUser.modelExpand.Get(uid, result); err != nil {
|
if err = this.moduleUser.modelExpand.Get(uid, result); err != nil && redis.RedisNil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = nil
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user