上传创号优化
This commit is contained in:
parent
dec719d2f2
commit
8254a62cfb
@ -32,17 +32,18 @@ func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateRe
|
||||
// 创角
|
||||
func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
res []*cfg.Gameatn
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
err error
|
||||
)
|
||||
|
||||
if errdata = this.CreateCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// resp := &pb.UserCreateResp{}
|
||||
uid := session.GetUserId()
|
||||
//获取用户
|
||||
self, err := this.module.modelUser.GetUser(session.GetUserId())
|
||||
user, err = this.module.modelUser.GetUser(session.GetUserId())
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
@ -53,7 +54,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
||||
}
|
||||
|
||||
//已否已创角
|
||||
if self.Created {
|
||||
if user.Created {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RoleCreated,
|
||||
Title: pb.ErrorCode_RoleCreated.ToString(),
|
||||
@ -69,14 +70,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//初始体力
|
||||
// var ps int32
|
||||
// gpd := this.module.configure.GetPlayerlvConf(self.Lv)
|
||||
// if gpd != nil {
|
||||
// ps = gpd.PsCeiling
|
||||
// }
|
||||
|
||||
update := map[string]interface{}{
|
||||
"name": req.NickName, //设置昵称
|
||||
"created": true, //创角标识
|
||||
@ -84,7 +77,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
||||
"gender": req.Gender, //设置性别
|
||||
"ps": 0, //设置初始体力 调整未0 由策划初始表发放
|
||||
}
|
||||
|
||||
globalConf := this.module.globalConf
|
||||
if req.Gender == 0 {
|
||||
update["avatar"] = globalConf.BoyHeadPortrait
|
||||
@ -92,40 +84,42 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
||||
update["avatar"] = globalConf.GirlHeadPortrait
|
||||
}
|
||||
|
||||
if err := this.module.modelUser.Change(uid, update); err != nil {
|
||||
if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
this.module.Error("创角",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
log.Field{Key: "params", Value: update},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
res []*cfg.Gameatn
|
||||
)
|
||||
|
||||
//初始化创角资源
|
||||
if val, err := this.module.configure.GetGlobalInitConf(); err == nil {
|
||||
for _, v := range val.GetDataList() {
|
||||
res = append(res, v.Var...)
|
||||
}
|
||||
_ = this.module.DispenseRes(session, res, true)
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{})
|
||||
if req.Figure != 0 {
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype72, 1))
|
||||
}
|
||||
this.mail.SendMailByCid(session, comm.Welcomemail, nil)
|
||||
if len(tasks) > 0 {
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{
|
||||
NickName: req.NickName,
|
||||
Figure: req.Figure,
|
||||
Gender: req.Gender,
|
||||
})
|
||||
|
||||
//异步逻辑
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
//初始化创角资源
|
||||
if val, err := this.module.configure.GetGlobalInitConf(); err == nil {
|
||||
for _, v := range val.GetDataList() {
|
||||
res = append(res, v.Var...)
|
||||
}
|
||||
if errdata := this.module.DispenseRes(session, res, true); errdata != nil {
|
||||
this.module.Error("发放资源失败!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: errdata.String()})
|
||||
}
|
||||
}
|
||||
this.mail.SendMailByCid(session, comm.Welcomemail, nil)
|
||||
if len(tasks) > 0 {
|
||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -1,43 +1,38 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
// func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
||||
// return
|
||||
// }
|
||||
|
||||
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
||||
return
|
||||
}
|
||||
// func (this *apiComp) Info(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
||||
// if errdata = this.InfoCheck(session, req); errdata != nil {
|
||||
// return
|
||||
// }
|
||||
|
||||
func (this *apiComp) Info(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
||||
if errdata = this.InfoCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
// dbUser, err := this.module.GetUser(session.GetUserId())
|
||||
// if err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// ue, err := this.module.GetUserExpand(session.GetUserId())
|
||||
// if err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
dbUser, err := this.module.GetUser(session.GetUserId())
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
ue, err := this.module.GetUserExpand(session.GetUserId())
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// rsp := &pb.UserInfoResp{
|
||||
// Data: dbUser,
|
||||
// Ex: ue,
|
||||
// }
|
||||
|
||||
rsp := &pb.UserInfoResp{
|
||||
Data: dbUser,
|
||||
Ex: ue,
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), UserSubTypeInfo, rsp)
|
||||
return
|
||||
}
|
||||
// session.SendMsg(string(this.module.GetType()), UserSubTypeInfo, rsp)
|
||||
// return
|
||||
// }
|
||||
|
@ -26,7 +26,6 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
||||
user *pb.DBUser
|
||||
expand *pb.DBUserExpand
|
||||
lastLoginTime int64
|
||||
update map[string]interface{} = make(map[string]interface{})
|
||||
err error
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
)
|
||||
@ -84,13 +83,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
||||
user.Channel = req.Channel
|
||||
user.Vcode = req.Vcode
|
||||
user.Vname = req.Vname
|
||||
update["logintime"] = user.Logintime
|
||||
update["lastloginip"] = user.Lastloginip
|
||||
update["offlinetime"] = user.Offlinetime
|
||||
update["Channel"] = user.Channel
|
||||
update["vcode"] = user.Vcode
|
||||
update["vname"] = user.Vname
|
||||
|
||||
update := utils.StructToMap(user)
|
||||
if expand, err = this.module.GetUserExpand(session.GetUserId()); err != nil {
|
||||
if err != mongo.ErrNoDocuments {
|
||||
errdata = &pb.ErrorData{
|
||||
|
1284
pb/user_msg.pb.go
1284
pb/user_msg.pb.go
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user