diff --git a/src/server/db/Mysql.go b/src/server/db/Mysql.go index a07bb5dc..309d5cdc 100644 --- a/src/server/db/Mysql.go +++ b/src/server/db/Mysql.go @@ -224,6 +224,12 @@ func GetPlayerBaseInfoFromDbByName(name string) *ResPlayerBaseInfo { return &res } +func UpdatePlayerBaseInfoName(oldName, newName string) error { + sqlStr := "UPDATE t_player_baseinfo SET user_name = ? WHERE user_name = ?" + _, err := SqlDb.Exec(sqlStr, newName, oldName) + return err +} + func GetPlayerBaseInfoFromDbById(id int32) *ResPlayerBaseInfo { sqlStr := "SELECT * FROM t_player_baseinfo WHERE dwUin = ?" var res ResPlayerBaseInfo @@ -238,7 +244,7 @@ func GetAccountInfoFromDb(name string) *Db_Account { sqlStr := "SELECT * FROM t_account WHERE user_name = ?" var res Db_Account if err := SqlDb.Get(&res, sqlStr, name); err != nil { - log.Debug("table: %s, sql :%s, exec failed, err:%v\n", "account", sqlStr, err) + log.Debug("登录的账号不存在:%s", name) return nil } return &res @@ -249,6 +255,11 @@ func UpdateAccountInfoToDb(account *Db_Account) (err error) { return } +func UpdateAccountInfoName(account *Db_Account, newName string) (err error) { + _, err = SqlDb.Exec("UPDATE t_account SET user_name = ? WHERE user_name = ?", newName, account.UserName) + return +} + func UpdateAccountInfoDeviceToDb(account *Db_Account) (err error) { _, err = SqlDb.Exec("UPDATE t_account SET device_id = ? WHERE user_name = ?", account.DeviceId, account.UserName) return diff --git a/src/server/game/admin.go b/src/server/game/admin.go index afce4997..59c8befc 100644 --- a/src/server/game/admin.go +++ b/src/server/game/admin.go @@ -46,7 +46,7 @@ func AdminProcess(Func string, args []interface{}) { log.Debug("AdminProcess error: %v", "Func not found") } -func VerifyUser(accountInfo *db.Db_Account, detail *msg.ReqLogin) (ResLogin *msg.ResLogin) { +func VerifyUser(accountInfo *db.Db_Account, detail *msg.ReqLogin) (ResLogin *msg.ResLogin, accountInfoOut *db.Db_Account) { if detail.Type == msg.LOGIN_TYPE_CODE_LOGIN { err := VerifyCode(detail.UserName, detail.Code) if err != nil { @@ -57,6 +57,16 @@ func VerifyUser(accountInfo *db.Db_Account, detail *msg.ReqLogin) (ResLogin *msg return } } + if detail.Type == msg.LOGIN_TYPE_SDK_LOGIN { + if accountInfo == nil { + accountInfo = db.GetAccountInfoFromDb(detail.Device) + } + if accountInfo != nil { + db.UpdateAccountInfoName(accountInfo, detail.UserName) + accountInfo.UserName = detail.UserName + db.UpdatePlayerBaseInfoName(detail.Device, detail.UserName) + } + } if accountInfo == nil { ResLogin = &msg.ResLogin{ ResultCode: MergeConst.Protocol_Error_Account_NoExsit, @@ -80,6 +90,7 @@ func VerifyUser(accountInfo *db.Db_Account, detail *msg.ReqLogin) (ResLogin *msg return } } + playerbaseinfo := db.GetPlayerBaseInfoFromDbByName(detail.UserName) if playerbaseinfo == nil { ResLogin = &msg.ResLogin{ @@ -96,7 +107,7 @@ func VerifyUser(accountInfo *db.Db_Account, detail *msg.ReqLogin) (ResLogin *msg } return } - + accountInfoOut = accountInfo ResLogin = &msg.ResLogin{ ResultCode: 0, DwUin: playerbaseinfo.DwUin, diff --git a/src/server/game/external.go b/src/server/game/external.go index 7e03472c..bd3dd209 100644 --- a/src/server/game/external.go +++ b/src/server/game/external.go @@ -163,7 +163,7 @@ func HandleClientReq(args []interface{}) { log.Error("uid : %d, func : %s, fatal : %s", 0, m.GetFunc(), r) } }() - ResLogin := VerifyUser(accountInfo, detail) + ResLogin, accountInfo := VerifyUser(accountInfo, detail) if ResLogin.ResultCode != 0 { G_GameLogicPtr.PackLoginResInfo(a, ResLogin) return diff --git a/src/server/msg/Gameapi.pb.go b/src/server/msg/Gameapi.pb.go index c4be126e..2388c474 100644 --- a/src/server/msg/Gameapi.pb.go +++ b/src/server/msg/Gameapi.pb.go @@ -616,6 +616,7 @@ const ( LOGIN_TYPE_ACCOUNT_LOGIN LOGIN_TYPE = 0 // 账号密码登录 LOGIN_TYPE_CODE_LOGIN LOGIN_TYPE = 1 // 验证码登录 LOGIN_TYPE_DEVICE_LOGIN LOGIN_TYPE = 2 // 设备号登录 + LOGIN_TYPE_SDK_LOGIN LOGIN_TYPE = 3 // 第三方SDK登录 ) // Enum value maps for LOGIN_TYPE. @@ -624,11 +625,13 @@ var ( 0: "ACCOUNT_LOGIN", 1: "CODE_LOGIN", 2: "DEVICE_LOGIN", + 3: "SDK_LOGIN", } LOGIN_TYPE_value = map[string]int32{ "ACCOUNT_LOGIN": 0, "CODE_LOGIN": 1, "DEVICE_LOGIN": 2, + "SDK_LOGIN": 3, } ) @@ -1872,6 +1875,7 @@ type ReqRegisterAccount struct { UserName string `protobuf:"bytes,1,opt,name=UserName,proto3" json:"UserName,omitempty"` UserPwd string `protobuf:"bytes,2,opt,name=UserPwd,proto3" json:"UserPwd,omitempty"` DwUin int32 `protobuf:"varint,3,opt,name=dwUin,proto3" json:"dwUin,omitempty"` + Device string `protobuf:"bytes,4,opt,name=Device,proto3" json:"Device,omitempty"` // 设备标识 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1927,6 +1931,13 @@ func (x *ReqRegisterAccount) GetDwUin() int32 { return 0 } +func (x *ReqRegisterAccount) GetDevice() string { + if x != nil { + return x.Device + } + return "" +} + // //响应注册账号 type ResRegisterAccount struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -14938,7 +14949,7 @@ func (x *ResFriendTimeLine) GetReply() []*ResFriendReply { type ResFriendReply struct { state protoimpl.MessageState `protogen:"open.v1"` Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 回复id - Type int32 `protobuf:"varint,2,opt,name=Type,proto3" json:"Type,omitempty"` // 回复类型 1:点赞 2:评论 + Type int32 `protobuf:"varint,2,opt,name=Type,proto3" json:"Type,omitempty"` // 回复类型 1:打招呼 2:被打招呼 Param string `protobuf:"bytes,3,opt,name=Param,proto3" json:"Param,omitempty"` // 回复内容 Status int32 `protobuf:"varint,4,opt,name=Status,proto3" json:"Status,omitempty"` // 状态 0:未处理 1:已处理 AddTime int64 `protobuf:"varint,5,opt,name=AddTime,proto3" json:"AddTime,omitempty"` // 添加时间 @@ -15031,6 +15042,7 @@ type ReqFriendReplyHandle struct { state protoimpl.MessageState `protogen:"open.v1"` LogId int32 `protobuf:"varint,1,opt,name=LogId,proto3" json:"LogId,omitempty"` // 时间线id Param string `protobuf:"bytes,2,opt,name=Param,proto3" json:"Param,omitempty"` // 回复内容 + Type int32 `protobuf:"varint,3,opt,name=Type,proto3" json:"Type,omitempty"` // 回复类型 1:打招呼 2:删除 3:查看 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -15079,6 +15091,13 @@ func (x *ReqFriendReplyHandle) GetParam() string { return "" } +func (x *ReqFriendReplyHandle) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + type ResFriendReplyHandle struct { state protoimpl.MessageState `protogen:"open.v1"` Code RES_CODE `protobuf:"varint,1,opt,name=Code,proto3,enum=tutorial.RES_CODE" json:"Code,omitempty"` @@ -27031,11 +27050,12 @@ const file_proto_Gameapi_proto_rawDesc = "" + "\tClientRes\x12\x12\n" + "\x04func\x18\x01 \x01(\tR\x04func\x12\x10\n" + "\x03cid\x18\x02 \x01(\tR\x03cid\x12\x12\n" + - "\x04info\x18\x03 \x01(\fR\x04info\"`\n" + + "\x04info\x18\x03 \x01(\fR\x04info\"x\n" + "\x12ReqRegisterAccount\x12\x1a\n" + "\bUserName\x18\x01 \x01(\tR\bUserName\x12\x18\n" + "\aUserPwd\x18\x02 \x01(\tR\aUserPwd\x12\x14\n" + - "\x05dwUin\x18\x03 \x01(\x05R\x05dwUin\"4\n" + + "\x05dwUin\x18\x03 \x01(\x05R\x05dwUin\x12\x16\n" + + "\x06Device\x18\x04 \x01(\tR\x06Device\"4\n" + "\x12ResRegisterAccount\x12\x1e\n" + "\n" + "ResultCode\x18\x01 \x01(\x05R\n" + @@ -28061,10 +28081,11 @@ const file_proto_Gameapi_proto_rawDesc = "" + "\x06Status\x18\x04 \x01(\x05R\x06Status\x12\x18\n" + "\aAddTime\x18\x05 \x01(\x03R\aAddTime\x12\x18\n" + "\aEndTime\x18\x06 \x01(\x03R\aEndTime\x121\n" + - "\x06Player\x18\a \x01(\v2\x19.tutorial.ResPlayerSimpleR\x06Player\"B\n" + + "\x06Player\x18\a \x01(\v2\x19.tutorial.ResPlayerSimpleR\x06Player\"V\n" + "\x14ReqFriendReplyHandle\x12\x14\n" + "\x05LogId\x18\x01 \x01(\x05R\x05LogId\x12\x14\n" + - "\x05Param\x18\x02 \x01(\tR\x05Param\"f\n" + + "\x05Param\x18\x02 \x01(\tR\x05Param\x12\x12\n" + + "\x04Type\x18\x03 \x01(\x05R\x04Type\"f\n" + "\x14ResFriendReplyHandle\x12&\n" + "\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" + "\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x14\n" + @@ -29078,13 +29099,14 @@ const file_proto_Gameapi_proto_rawDesc = "" + "\fPreview_type\x10\f\x12\x0e\n" + "\n" + "Fixed_type\x10\r\x12\x11\n" + - "\rPlayroom_type\x10\x0e*A\n" + + "\rPlayroom_type\x10\x0e*P\n" + "\n" + "LOGIN_TYPE\x12\x11\n" + "\rACCOUNT_LOGIN\x10\x00\x12\x0e\n" + "\n" + "CODE_LOGIN\x10\x01\x12\x10\n" + - "\fDEVICE_LOGIN\x10\x02*\xb9\x06\n" + + "\fDEVICE_LOGIN\x10\x02\x12\r\n" + + "\tSDK_LOGIN\x10\x03*\xb9\x06\n" + "\x0eTIME_LINE_TYPE\x12\v\n" + "\aDEFAULT\x10\x00\x12\x19\n" + "\x15LOG_TYPE_FRIEND_APPLY\x10\x01\x12\x1a\n" +