上传创号优化
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) {
|
func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
|
user *pb.DBUser
|
||||||
|
res []*cfg.Gameatn
|
||||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if errdata = this.CreateCheck(session, req); errdata != nil {
|
if errdata = this.CreateCheck(session, req); errdata != nil {
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_UserNofound,
|
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{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_RoleCreated,
|
Code: pb.ErrorCode_RoleCreated,
|
||||||
Title: pb.ErrorCode_RoleCreated.ToString(),
|
Title: pb.ErrorCode_RoleCreated.ToString(),
|
||||||
@ -69,14 +70,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始体力
|
|
||||||
// var ps int32
|
|
||||||
// gpd := this.module.configure.GetPlayerlvConf(self.Lv)
|
|
||||||
// if gpd != nil {
|
|
||||||
// ps = gpd.PsCeiling
|
|
||||||
// }
|
|
||||||
|
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"name": req.NickName, //设置昵称
|
"name": req.NickName, //设置昵称
|
||||||
"created": true, //创角标识
|
"created": true, //创角标识
|
||||||
@ -84,7 +77,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
|||||||
"gender": req.Gender, //设置性别
|
"gender": req.Gender, //设置性别
|
||||||
"ps": 0, //设置初始体力 调整未0 由策划初始表发放
|
"ps": 0, //设置初始体力 调整未0 由策划初始表发放
|
||||||
}
|
}
|
||||||
|
|
||||||
globalConf := this.module.globalConf
|
globalConf := this.module.globalConf
|
||||||
if req.Gender == 0 {
|
if req.Gender == 0 {
|
||||||
update["avatar"] = globalConf.BoyHeadPortrait
|
update["avatar"] = globalConf.BoyHeadPortrait
|
||||||
@ -92,40 +84,42 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
|
|||||||
update["avatar"] = globalConf.GirlHeadPortrait
|
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{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
}
|
}
|
||||||
this.module.Error("创角",
|
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: "params", Value: update},
|
||||||
log.Field{Key: "err", Value: err.Error()},
|
log.Field{Key: "err", Value: err.Error()},
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.Figure != 0 {
|
||||||
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype72, 1))
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{
|
||||||
|
NickName: req.NickName,
|
||||||
|
Figure: req.Figure,
|
||||||
|
Gender: req.Gender,
|
||||||
|
})
|
||||||
|
|
||||||
var (
|
//异步逻辑
|
||||||
res []*cfg.Gameatn
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||||
)
|
|
||||||
|
|
||||||
//初始化创角资源
|
//初始化创角资源
|
||||||
if val, err := this.module.configure.GetGlobalInitConf(); err == nil {
|
if val, err := this.module.configure.GetGlobalInitConf(); err == nil {
|
||||||
for _, v := range val.GetDataList() {
|
for _, v := range val.GetDataList() {
|
||||||
res = append(res, v.Var...)
|
res = append(res, v.Var...)
|
||||||
}
|
}
|
||||||
_ = this.module.DispenseRes(session, res, true)
|
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()})
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
this.mail.SendMailByCid(session, comm.Welcomemail, nil)
|
||||||
if len(tasks) > 0 {
|
if len(tasks) > 0 {
|
||||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
||||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,38 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
// func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
||||||
"go_dreamfactory/comm"
|
// return
|
||||||
"go_dreamfactory/pb"
|
// }
|
||||||
)
|
|
||||||
|
|
||||||
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
// func (this *apiComp) Info(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
||||||
return
|
// if errdata = this.InfoCheck(session, req); errdata != nil {
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
func (this *apiComp) Info(session comm.IUserSession, req *pb.UserInfoReq) (errdata *pb.ErrorData) {
|
// dbUser, err := this.module.GetUser(session.GetUserId())
|
||||||
if errdata = this.InfoCheck(session, req); errdata != nil {
|
// if err != nil {
|
||||||
return
|
// 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())
|
// rsp := &pb.UserInfoResp{
|
||||||
if err != nil {
|
// Data: dbUser,
|
||||||
errdata = &pb.ErrorData{
|
// Ex: ue,
|
||||||
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{
|
// session.SendMsg(string(this.module.GetType()), UserSubTypeInfo, rsp)
|
||||||
Data: dbUser,
|
// return
|
||||||
Ex: ue,
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
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
|
user *pb.DBUser
|
||||||
expand *pb.DBUserExpand
|
expand *pb.DBUserExpand
|
||||||
lastLoginTime int64
|
lastLoginTime int64
|
||||||
update map[string]interface{} = make(map[string]interface{})
|
|
||||||
err error
|
err error
|
||||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
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.Channel = req.Channel
|
||||||
user.Vcode = req.Vcode
|
user.Vcode = req.Vcode
|
||||||
user.Vname = req.Vname
|
user.Vname = req.Vname
|
||||||
update["logintime"] = user.Logintime
|
update := utils.StructToMap(user)
|
||||||
update["lastloginip"] = user.Lastloginip
|
|
||||||
update["offlinetime"] = user.Offlinetime
|
|
||||||
update["Channel"] = user.Channel
|
|
||||||
update["vcode"] = user.Vcode
|
|
||||||
update["vname"] = user.Vname
|
|
||||||
|
|
||||||
if expand, err = this.module.GetUserExpand(session.GetUserId()); err != nil {
|
if expand, err = this.module.GetUserExpand(session.GetUserId()); err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
errdata = &pb.ErrorData{
|
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