캐릭터 생성 성공시 전달하는 결과 값 변경
- 생성된 캐릭터 정보를 바로 보내서 클라에서 캐릭터 정보를 바로 update 하도록 한다
This commit is contained in:
@ -317,8 +317,9 @@ func (tx *transaction) UpdateCharInfo(charSlotId int32, raw map[string]interface
|
|||||||
q, err := tx.gs.mongoClient.FindOne("PlayerInfo", bson.M{"_id": playerid, "charInfo.slotId": charSlotId},
|
q, err := tx.gs.mongoClient.FindOne("PlayerInfo", bson.M{"_id": playerid, "charInfo.slotId": charSlotId},
|
||||||
options.FindOne().SetProjection(bson.M{"charInfo.$": 1}))
|
options.FindOne().SetProjection(bson.M{"charInfo.$": 1}))
|
||||||
|
|
||||||
|
var info map[string]interface{}
|
||||||
if q == nil {
|
if q == nil {
|
||||||
info := raw
|
info = raw
|
||||||
info["slotId"] = charSlotId
|
info["slotId"] = charSlotId
|
||||||
|
|
||||||
tx.gs.Logger.Println("new info", info)
|
tx.gs.Logger.Println("new info", info)
|
||||||
@ -331,7 +332,7 @@ func (tx *transaction) UpdateCharInfo(charSlotId int32, raw map[string]interface
|
|||||||
},
|
},
|
||||||
options.Update().SetUpsert(true))
|
options.Update().SetUpsert(true))
|
||||||
} else {
|
} else {
|
||||||
info := q["charInfo"].(bson.A)[0].(map[string]interface{})
|
info = q["charInfo"].(bson.A)[0].(map[string]interface{})
|
||||||
tx.gs.Logger.Println("current info", info)
|
tx.gs.Logger.Println("current info", info)
|
||||||
|
|
||||||
for k, v := range raw {
|
for k, v := range raw {
|
||||||
@ -359,7 +360,8 @@ func (tx *transaction) UpdateCharInfo(charSlotId int32, raw map[string]interface
|
|||||||
// }, options.Update().SetUpsert(true))
|
// }, options.Update().SetUpsert(true))
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return shared.MakeRPCReturn("update success", err)
|
doc := bson.M(info)
|
||||||
|
return shared.MakeRPCReturn(doc, nil)
|
||||||
} else {
|
} else {
|
||||||
return shared.MakeRPCReturn(nil, errors.New("invalid body"))
|
return shared.MakeRPCReturn(nil, errors.New("invalid body"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user