优化userErrCode
This commit is contained in:
parent
64e9ff0fe7
commit
0fd9bac9f9
@ -6,6 +6,9 @@ import (
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -68,3 +71,10 @@ func (this *apiComp) Start() (err error) {
|
||||
this.chat = module.(comm.IChat)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) sendMsg(session comm.IUserSession, subType string, rsp proto.Message) {
|
||||
if err := session.SendMsg(string(this.module.GetType()), subType, rsp); err != nil {
|
||||
this.module.Error("User sendMsg err", log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
||||
return
|
||||
}
|
||||
|
||||
resp := &pb.UserCreateResp{}
|
||||
uid := session.GetUserId()
|
||||
//获取用户
|
||||
self := this.module.modelUser.GetUser(session.GetUserId())
|
||||
@ -43,7 +44,8 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
||||
|
||||
//查询昵称是否重复
|
||||
if ok := this.module.modelUser.NickNameIsExist(req.NickName); !ok {
|
||||
code = pb.ErrorCode_UserNickNameExist
|
||||
resp.Code = pb.ErrorCode_UserNickNameExist
|
||||
this.sendMsg(session, UserSubTypeCreate, resp)
|
||||
return
|
||||
}
|
||||
|
||||
@ -116,9 +118,8 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
||||
// }
|
||||
|
||||
// }()
|
||||
if err := session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{IsSucc: true}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
resp.IsSucc = true
|
||||
this.sendMsg(session, UserSubTypeCreate, resp)
|
||||
|
||||
if req.Figure != 0 {
|
||||
go this.module.ModuleRtask.TriggerTask(uid, comm.GettaskParam(comm.Rtype72, 1))
|
||||
|
@ -17,15 +17,17 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
|
||||
if code = this.ModifynameCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
uid := session.GetUserId()
|
||||
resp := &pb.UserModifynameResp{Uid: uid, Name: req.Name}
|
||||
name := strings.TrimSpace(req.Name)
|
||||
//验证名称
|
||||
if !this.module.modelUser.NickNameIsExist(name) {
|
||||
code = pb.ErrorCode_UserNickNameExist
|
||||
resp.Code = pb.ErrorCode_UserNickNameExist
|
||||
this.sendMsg(session, UserSubTypeModifyName, resp)
|
||||
return
|
||||
}
|
||||
|
||||
expand, err := this.module.modelExpand.GetUserExpand(session.GetUserId())
|
||||
expand, err := this.module.modelExpand.GetUserExpand(uid)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
@ -37,7 +39,7 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
this.module.Infof("修改昵称 uid:%v 消耗:%v code:%v", session.GetUserId(), this.module.globalConf.HeroName, code)
|
||||
this.module.Infof("修改昵称 uid:%v 消耗:%v code:%v", uid, this.module.globalConf.HeroName, code)
|
||||
}
|
||||
|
||||
//修改名称次数
|
||||
@ -48,24 +50,19 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
|
||||
mc := map[string]interface{}{
|
||||
"modifynameCount": left,
|
||||
}
|
||||
if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), mc); err != nil {
|
||||
if err := this.module.modelExpand.ChangeUserExpand(uid, mc); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("更新昵称失败 uid:%v name:%v err:%v", session.GetUserId(), req.Name, err)
|
||||
this.module.Errorf("更新昵称失败 uid:%v name:%v err:%v", uid, req.Name, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 修改名称
|
||||
if code = this.module.modelUser.modifyName(session.GetUserId(), name); code != pb.ErrorCode_Success {
|
||||
if code = this.module.modelUser.modifyName(uid, name); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if err = session.SendMsg(string(this.module.GetType()), UserSubTypeModifyName, &pb.UserModifynameResp{
|
||||
Uid: session.GetUserId(),
|
||||
Count: uint32(left),
|
||||
Name: req.Name,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
resp.Count = uint32(left)
|
||||
this.sendMsg(session, UserSubTypeModifyName, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -2,10 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// 参数校验
|
||||
@ -25,10 +22,3 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) sendMsg(session comm.IUserSession, subType string, rsp proto.Message) {
|
||||
if err := session.SendMsg(string(this.module.GetType()), subType, rsp); err != nil {
|
||||
this.module.Error("UserModule sendMsg err", log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +569,8 @@ type UserCreateResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
IsSucc bool `protobuf:"varint,1,opt,name=IsSucc,proto3" json:"IsSucc"`
|
||||
IsSucc bool `protobuf:"varint,1,opt,name=IsSucc,proto3" json:"IsSucc"`
|
||||
Code ErrorCode `protobuf:"varint,2,opt,name=code,proto3,enum=ErrorCode" json:"code"`
|
||||
}
|
||||
|
||||
func (x *UserCreateResp) Reset() {
|
||||
@ -611,6 +612,13 @@ func (x *UserCreateResp) GetIsSucc() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *UserCreateResp) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
// 玩家资源变更推送
|
||||
type UserResChangedPush struct {
|
||||
state protoimpl.MessageState
|
||||
@ -1281,9 +1289,10 @@ type UserModifynameResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
|
||||
Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count"` //剩余修改次数
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name"`
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
|
||||
Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count"` //剩余修改次数
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name"`
|
||||
Code ErrorCode `protobuf:"varint,4,opt,name=code,proto3,enum=ErrorCode" json:"code"`
|
||||
}
|
||||
|
||||
func (x *UserModifynameResp) Reset() {
|
||||
@ -1339,6 +1348,13 @@ func (x *UserModifynameResp) GetName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserModifynameResp) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
// 修改头像
|
||||
type UserModifyavatarReq struct {
|
||||
state protoimpl.MessageState
|
||||
@ -3089,10 +3105,12 @@ var file_user_user_msg_proto_rawDesc = []byte{
|
||||
0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69,
|
||||
0x67, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x66, 0x69, 0x67, 0x75,
|
||||
0x72, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x28, 0x0a, 0x0e, 0x55, 0x73,
|
||||
0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x48, 0x0a, 0x0e, 0x55, 0x73,
|
||||
0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x49, 0x73, 0x53, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73,
|
||||
0x53, 0x75, 0x63, 0x63, 0x22, 0x96, 0x03, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73,
|
||||
0x53, 0x75, 0x63, 0x63, 0x12, 0x1e, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
|
||||
0x63, 0x6f, 0x64, 0x65, 0x22, 0x96, 0x03, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73,
|
||||
0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x50, 0x75, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x67,
|
||||
0x6f, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x12,
|
||||
0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x65, 0x78,
|
||||
@ -3146,12 +3164,14 @@ var file_user_user_msg_proto_rawDesc = []byte{
|
||||
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0x27, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72,
|
||||
0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x22, 0x50, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x6e,
|
||||
0x65, 0x22, 0x70, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x6e,
|
||||
0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
|
||||
0x61, 0x6d, 0x65, 0x22, 0x31, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66,
|
||||
0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x22, 0x31, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66,
|
||||
0x79, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x76,
|
||||
0x61, 0x74, 0x61, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x76,
|
||||
0x61, 0x74, 0x61, 0x72, 0x49, 0x64, 0x22, 0x44, 0x0a, 0x14, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f,
|
||||
@ -3371,25 +3391,27 @@ var file_user_user_msg_proto_depIdxs = []int32{
|
||||
58, // 3: UserInfoResp.ex:type_name -> DBUserExpand
|
||||
59, // 4: UserRegisterResp.Code:type_name -> ErrorCode
|
||||
60, // 5: UserLoadResp.data:type_name -> CacheUser
|
||||
61, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
|
||||
61, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
|
||||
57, // 8: UserBattlerecordResp.data:type_name -> DBUser
|
||||
58, // 9: UserBattlerecordResp.ex:type_name -> DBUserExpand
|
||||
62, // 10: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord
|
||||
63, // 11: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank
|
||||
64, // 12: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank
|
||||
60, // 13: UserOnlineResp.users:type_name -> CacheUser
|
||||
57, // 14: UserDataListResp.users:type_name -> DBUser
|
||||
65, // 15: UserGetServerDataResp.data:type_name -> DBServerData
|
||||
66, // 16: UserSignResp.data:type_name -> DBSign
|
||||
66, // 17: UserChangeTipsResp.data:type_name -> DBSign
|
||||
67, // 18: UserSellResReq.atno:type_name -> UserAtno
|
||||
68, // 19: UserSellResResp.atn:type_name -> UserAssets
|
||||
20, // [20:20] is the sub-list for method output_type
|
||||
20, // [20:20] is the sub-list for method input_type
|
||||
20, // [20:20] is the sub-list for extension type_name
|
||||
20, // [20:20] is the sub-list for extension extendee
|
||||
0, // [0:20] is the sub-list for field type_name
|
||||
59, // 6: UserCreateResp.code:type_name -> ErrorCode
|
||||
61, // 7: UserGetSettingResp.setting:type_name -> DBUserSetting
|
||||
61, // 8: UserUpdateSettingReq.setting:type_name -> DBUserSetting
|
||||
59, // 9: UserModifynameResp.code:type_name -> ErrorCode
|
||||
57, // 10: UserBattlerecordResp.data:type_name -> DBUser
|
||||
58, // 11: UserBattlerecordResp.ex:type_name -> DBUserExpand
|
||||
62, // 12: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord
|
||||
63, // 13: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank
|
||||
64, // 14: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank
|
||||
60, // 15: UserOnlineResp.users:type_name -> CacheUser
|
||||
57, // 16: UserDataListResp.users:type_name -> DBUser
|
||||
65, // 17: UserGetServerDataResp.data:type_name -> DBServerData
|
||||
66, // 18: UserSignResp.data:type_name -> DBSign
|
||||
66, // 19: UserChangeTipsResp.data:type_name -> DBSign
|
||||
67, // 20: UserSellResReq.atno:type_name -> UserAtno
|
||||
68, // 21: UserSellResResp.atn:type_name -> UserAssets
|
||||
22, // [22:22] is the sub-list for method output_type
|
||||
22, // [22:22] is the sub-list for method input_type
|
||||
22, // [22:22] is the sub-list for extension type_name
|
||||
22, // [22:22] is the sub-list for extension extendee
|
||||
0, // [0:22] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_user_user_msg_proto_init() }
|
||||
|
Loading…
Reference in New Issue
Block a user