修复金币初始化
This commit is contained in:
parent
13648d9471
commit
491b7a271e
@ -17,7 +17,7 @@ var user_builders = []*TestCase{
|
|||||||
NickName: "乐谷6301",
|
NickName: "乐谷6301",
|
||||||
},
|
},
|
||||||
rsp: &pb.UserCreateResp{},
|
rsp: &pb.UserCreateResp{},
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
}, {
|
}, {
|
||||||
Desc: "添加资源",
|
Desc: "添加资源",
|
||||||
mainType: string(comm.ModuleUser),
|
mainType: string(comm.ModuleUser),
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"github.com/spf13/cast"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
|
|
||||||
//设置初始金币
|
//设置初始金币
|
||||||
if val := this.module.configure.GetGlobalConf("init_gold"); val != "" {
|
if val := this.module.configure.GetGlobalConf("init_gold"); val != "" {
|
||||||
update["gold"] = val
|
update["gold"] = cast.ToInt32(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = this.module.modelUser.Change(session.GetUserId(), update)
|
err = this.module.modelUser.Change(session.GetUserId(), update)
|
||||||
|
@ -14,7 +14,9 @@ import (
|
|||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) (code pb.ErrorCode) {
|
func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) (code pb.ErrorCode) {
|
||||||
|
if req.Account == "" {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,17 +40,19 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
||||||
//从mgo查询user
|
//从mgo查询user
|
||||||
user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account)
|
user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
|
log.Errorf("User_FindByAccount err %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
|
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
|
||||||
user = &pb.DBUser{}
|
user = &pb.DBUser{Sid: req.Sid, Binduid: req.Account}
|
||||||
err = this.module.modelUser.User_Create(user)
|
err = this.module.modelUser.User_Create(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("User_CreateUser err %v", err)
|
log.Errorf("User_CreateUser err %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user