修复imserver数据库问题
This commit is contained in:
parent
68d2a07d51
commit
5c85db77f9
@ -27,8 +27,8 @@ func (cm *CacheMgr) LoadFromDB() {
|
|||||||
empty := true
|
empty := true
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
empty = false
|
empty = false
|
||||||
account1Id := q5.ToString(*rows.GetByName("account1_id"))
|
account1Id := q5.ToString(rows.GetByName("account1_id"))
|
||||||
account2Id := q5.ToString(*rows.GetByName("account2_id"))
|
account2Id := q5.ToString(rows.GetByName("account2_id"))
|
||||||
|
|
||||||
if !uniAccountIds.Has(account1Id) {
|
if !uniAccountIds.Has(account1Id) {
|
||||||
cm.loadUserProfile(account1Id)
|
cm.loadUserProfile(account1Id)
|
||||||
@ -40,7 +40,7 @@ func (cm *CacheMgr) LoadFromDB() {
|
|||||||
}
|
}
|
||||||
uniAccountIds.Add(account2Id)
|
uniAccountIds.Add(account2Id)
|
||||||
|
|
||||||
lastIdx = q5.ToInt64(*rows.GetByName("idx"))
|
lastIdx = q5.ToInt64(rows.GetByName("idx"))
|
||||||
}
|
}
|
||||||
if empty {
|
if empty {
|
||||||
done = true
|
done = true
|
||||||
@ -66,14 +66,14 @@ func (cm *CacheMgr) LoadFromDB() {
|
|||||||
empty := true
|
empty := true
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
empty = false
|
empty = false
|
||||||
accountId := q5.ToString(*rows.GetByName("account_id"))
|
accountId := q5.ToString(rows.GetByName("account_id"))
|
||||||
|
|
||||||
if !uniAccountIds.Has(accountId) {
|
if !uniAccountIds.Has(accountId) {
|
||||||
cm.loadUserProfile(accountId)
|
cm.loadUserProfile(accountId)
|
||||||
}
|
}
|
||||||
uniAccountIds.Add(accountId)
|
uniAccountIds.Add(accountId)
|
||||||
|
|
||||||
lastIdx = q5.ToInt64(*rows.GetByName("idx"))
|
lastIdx = q5.ToInt64(rows.GetByName("idx"))
|
||||||
}
|
}
|
||||||
if empty {
|
if empty {
|
||||||
done = true
|
done = true
|
||||||
@ -98,16 +98,16 @@ func (cm *CacheMgr) loadUserProfile(accountId string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
aId := q5.ToString(*rows.GetByName("account_id"))
|
aId := q5.ToString(rows.GetByName("account_id"))
|
||||||
onlineStatus := playerMgr.GetOnlineStatus(accountId)
|
onlineStatus := playerMgr.GetOnlineStatus(accountId)
|
||||||
profile := &PlayerProfile{
|
profile := &PlayerProfile{
|
||||||
AccountId: aId,
|
AccountId: aId,
|
||||||
Username: q5.ToString(*rows.GetByName("name")),
|
Username: q5.ToString(rows.GetByName("name")),
|
||||||
Avatar: q5.ToInt32(*rows.GetByName("head_id")),
|
Avatar: q5.ToInt32(rows.GetByName("head_id")),
|
||||||
AvatarHead: q5.ToInt32(*rows.GetByName("head_frame")),
|
AvatarHead: q5.ToInt32(rows.GetByName("head_frame")),
|
||||||
Star: q5.ToInt32(*rows.GetByName("star_num")),
|
Star: q5.ToInt32(rows.GetByName("star_num")),
|
||||||
Rank: q5.ToInt32(*rows.GetByName("rank")),
|
Rank: q5.ToInt32(rows.GetByName("rank")),
|
||||||
LastLoginTime: q5.ToInt32(*rows.GetByName("last_login_time")),
|
LastLoginTime: q5.ToInt32(rows.GetByName("last_login_time")),
|
||||||
OnlineStatus: onlineStatus,
|
OnlineStatus: onlineStatus,
|
||||||
}
|
}
|
||||||
cm.AddPlayerProfile(cm.getCacheVersion(), profile)
|
cm.AddPlayerProfile(cm.getCacheVersion(), profile)
|
||||||
|
@ -501,8 +501,9 @@ var file_cs_msgid_proto_rawDesc = []byte{
|
|||||||
0x66, 0x79, 0x10, 0xf4, 0x07, 0x12, 0x1a, 0x0a, 0x15, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c,
|
0x66, 0x79, 0x10, 0xf4, 0x07, 0x12, 0x1a, 0x0a, 0x15, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c,
|
||||||
0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf5,
|
0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf5,
|
||||||
0x07, 0x12, 0x18, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69,
|
0x07, 0x12, 0x18, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69,
|
||||||
0x6c, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf6, 0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
0x6c, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf6, 0x07, 0x42, 0x1a, 0x0a, 0x12, 0x63,
|
||||||
0x3b, 0x63, 0x73,
|
0x73, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x5f, 0x70,
|
||||||
|
0x62, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -6161,7 +6161,8 @@ var file_cs_proto_proto_rawDesc = []byte{
|
|||||||
0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, 0x2a, 0x22, 0x0a, 0x0a, 0x43,
|
0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, 0x2a, 0x22, 0x0a, 0x0a, 0x43,
|
||||||
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f,
|
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f,
|
||||||
0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42,
|
0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42,
|
||||||
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
0x1a, 0x0a, 0x12, 0x63, 0x73, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x72, 0x6f,
|
||||||
|
0x74, 0x6f, 0x5f, 0x70, 0x62, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -106,20 +106,20 @@ func (fm *FriendsMgr) findUsersByUsername(username string, sinceId int64, cb fun
|
|||||||
lastId := sinceId
|
lastId := sinceId
|
||||||
profiles := make([]*PlayerProfile, 0, MaxSearchResults)
|
profiles := make([]*PlayerProfile, 0, MaxSearchResults)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
autoId := q5.ToInt64(*rows.GetByIndex(0))
|
autoId := q5.ToInt64(rows.GetByIndex(0))
|
||||||
if autoId > lastId {
|
if autoId > lastId {
|
||||||
lastId = autoId
|
lastId = autoId
|
||||||
}
|
}
|
||||||
accountId := q5.ToString(*rows.GetByIndex(1))
|
accountId := q5.ToString(rows.GetByIndex(1))
|
||||||
onlineStatus := playerMgr.GetOnlineStatus(accountId)
|
onlineStatus := playerMgr.GetOnlineStatus(accountId)
|
||||||
profile := &PlayerProfile{
|
profile := &PlayerProfile{
|
||||||
AccountId: q5.ToString(*rows.GetByIndex(1)),
|
AccountId: q5.ToString(rows.GetByIndex(1)),
|
||||||
Username: q5.ToString(*rows.GetByIndex(2)),
|
Username: q5.ToString(rows.GetByIndex(2)),
|
||||||
Avatar: q5.ToInt32(*rows.GetByIndex(3)),
|
Avatar: q5.ToInt32(rows.GetByIndex(3)),
|
||||||
AvatarHead: q5.ToInt32(*rows.GetByIndex(4)),
|
AvatarHead: q5.ToInt32(rows.GetByIndex(4)),
|
||||||
Star: q5.ToInt32(*rows.GetByIndex(5)),
|
Star: q5.ToInt32(rows.GetByIndex(5)),
|
||||||
Rank: q5.ToInt32(*rows.GetByIndex(6)),
|
Rank: q5.ToInt32(rows.GetByIndex(6)),
|
||||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(7)),
|
LastLoginTime: q5.ToInt32(rows.GetByIndex(7)),
|
||||||
OnlineStatus: onlineStatus,
|
OnlineStatus: onlineStatus,
|
||||||
}
|
}
|
||||||
profiles = append(profiles, profile)
|
profiles = append(profiles, profile)
|
||||||
@ -144,10 +144,10 @@ func (fm *FriendsMgr) loadFriendships() {
|
|||||||
}
|
}
|
||||||
userMap := make(map[string]*User)
|
userMap := make(map[string]*User)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
account1Id := q5.ToString(*rows.GetByIndex(0))
|
account1Id := q5.ToString(rows.GetByIndex(0))
|
||||||
account2Id := q5.ToString(*rows.GetByIndex(1))
|
account2Id := q5.ToString(rows.GetByIndex(1))
|
||||||
isFriendship := q5.ToInt32(*rows.GetByIndex(2))
|
isFriendship := q5.ToInt32(rows.GetByIndex(2))
|
||||||
requestTime := q5.ToInt64(*rows.GetByIndex(3))
|
requestTime := q5.ToInt64(rows.GetByIndex(3))
|
||||||
// 检查用户是否已经存在,如果不存在则创建
|
// 检查用户是否已经存在,如果不存在则创建
|
||||||
user1, exists1 := userMap[account1Id]
|
user1, exists1 := userMap[account1Id]
|
||||||
if !exists1 {
|
if !exists1 {
|
||||||
@ -192,10 +192,10 @@ func (fm *FriendsMgr) loadUserFriendships(user *User, where [][]string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
account1Id := q5.ToString(*rows.GetByIndex(0))
|
account1Id := q5.ToString(rows.GetByIndex(0))
|
||||||
account2Id := q5.ToString(*rows.GetByIndex(1))
|
account2Id := q5.ToString(rows.GetByIndex(1))
|
||||||
isFriendship := q5.ToInt32(*rows.GetByIndex(2))
|
isFriendship := q5.ToInt32(rows.GetByIndex(2))
|
||||||
requestTime := q5.ToInt64(*rows.GetByIndex(3))
|
requestTime := q5.ToInt64(rows.GetByIndex(3))
|
||||||
if user.AccountId == account1Id {
|
if user.AccountId == account1Id {
|
||||||
friendship1 := &Friendship{
|
friendship1 := &Friendship{
|
||||||
FriendAccountId: account2Id,
|
FriendAccountId: account2Id,
|
||||||
@ -247,8 +247,8 @@ func (fm *FriendsMgr) loadBlacklist() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
account1Id := q5.ToString(*rows.GetByIndex(0))
|
account1Id := q5.ToString(rows.GetByIndex(0))
|
||||||
account2Id := q5.ToString(*rows.GetByIndex(1))
|
account2Id := q5.ToString(rows.GetByIndex(1))
|
||||||
friendBlackList := &FriendBlackList{
|
friendBlackList := &FriendBlackList{
|
||||||
AccountId: account2Id,
|
AccountId: account2Id,
|
||||||
IsRemoved: 0,
|
IsRemoved: 0,
|
||||||
|
@ -40,20 +40,20 @@ func (gm *GuildMgr) loadGuildFromDBResult(err error, rows *f5.DataSet) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
guildId := q5.ToInt64(*rows.GetByIndex(1))
|
guildId := q5.ToInt64(rows.GetByIndex(1))
|
||||||
guild := &Guild{
|
guild := &Guild{
|
||||||
AutoId: q5.ToInt64(*rows.GetByIndex(0)),
|
AutoId: q5.ToInt64(rows.GetByIndex(0)),
|
||||||
GuildId: guildId,
|
GuildId: guildId,
|
||||||
Name: q5.ToString(*rows.GetByIndex(2)),
|
Name: q5.ToString(rows.GetByIndex(2)),
|
||||||
LeaderId: q5.ToString(*rows.GetByIndex(3)),
|
LeaderId: q5.ToString(rows.GetByIndex(3)),
|
||||||
Avatar: q5.ToInt32(*rows.GetByIndex(4)),
|
Avatar: q5.ToInt32(rows.GetByIndex(4)),
|
||||||
Notice: q5.ToString(*rows.GetByIndex(5)),
|
Notice: q5.ToString(rows.GetByIndex(5)),
|
||||||
JoinCond: q5.ToInt32(*rows.GetByIndex(6)),
|
JoinCond: q5.ToInt32(rows.GetByIndex(6)),
|
||||||
JoinCondValue: q5.ToInt32(*rows.GetByIndex(7)),
|
JoinCondValue: q5.ToInt32(rows.GetByIndex(7)),
|
||||||
TotalStars: q5.ToInt32(*rows.GetByIndex(8)),
|
TotalStars: q5.ToInt32(rows.GetByIndex(8)),
|
||||||
TotalKills: q5.ToInt32(*rows.GetByIndex(9)),
|
TotalKills: q5.ToInt32(rows.GetByIndex(9)),
|
||||||
ChickenDinners: q5.ToInt32(*rows.GetByIndex(10)),
|
ChickenDinners: q5.ToInt32(rows.GetByIndex(10)),
|
||||||
MaxMembers: q5.ToInt32(*rows.GetByIndex(11)),
|
MaxMembers: q5.ToInt32(rows.GetByIndex(11)),
|
||||||
Members: make(map[string]*GuildMember, MaxMembers),
|
Members: make(map[string]*GuildMember, MaxMembers),
|
||||||
PendingReqs: make(map[string]int32, MaxPendingReqs),
|
PendingReqs: make(map[string]int32, MaxPendingReqs),
|
||||||
}
|
}
|
||||||
@ -88,9 +88,9 @@ func (gm *GuildMgr) loadGuildMemberFromDBResult(err error, rows *f5.DataSet) {
|
|||||||
accountId string
|
accountId string
|
||||||
level int32
|
level int32
|
||||||
)
|
)
|
||||||
guildId = q5.ToInt64(*rows.GetByIndex(0))
|
guildId = q5.ToInt64(rows.GetByIndex(0))
|
||||||
accountId = q5.ToString(*rows.GetByIndex(1))
|
accountId = q5.ToString(rows.GetByIndex(1))
|
||||||
level = q5.ToInt32(*rows.GetByIndex(2))
|
level = q5.ToInt32(rows.GetByIndex(2))
|
||||||
|
|
||||||
guildMember := &GuildMember{
|
guildMember := &GuildMember{
|
||||||
AccountId: accountId,
|
AccountId: accountId,
|
||||||
@ -128,8 +128,8 @@ func (gm *GuildMgr) loadPendingReqsFromDBResult(err error, rows *f5.DataSet) {
|
|||||||
guildId int64
|
guildId int64
|
||||||
accountId string
|
accountId string
|
||||||
)
|
)
|
||||||
guildId = q5.ToInt64(*rows.GetByIndex(0))
|
guildId = q5.ToInt64(rows.GetByIndex(0))
|
||||||
accountId = q5.ToString(*rows.GetByIndex(1))
|
accountId = q5.ToString(rows.GetByIndex(1))
|
||||||
|
|
||||||
pendingReq := &PendingReq{
|
pendingReq := &PendingReq{
|
||||||
AccountId: accountId,
|
AccountId: accountId,
|
||||||
@ -176,10 +176,10 @@ func (gm *GuildMgr) loadGuildLogsFromDBResult(err error, pagination *f5.Paginati
|
|||||||
gm.guildLogs[guildId] = make([]*GuildLog, DefaultLogs)
|
gm.guildLogs[guildId] = make([]*GuildLog, DefaultLogs)
|
||||||
|
|
||||||
for pagination.Rows.Next() {
|
for pagination.Rows.Next() {
|
||||||
guildId = q5.ToInt64(*pagination.Rows.GetByIndex(0))
|
guildId = q5.ToInt64(pagination.Rows.GetByIndex(0))
|
||||||
accountId = q5.ToString(*pagination.Rows.GetByIndex(1))
|
accountId = q5.ToString(pagination.Rows.GetByIndex(1))
|
||||||
logType = q5.ToInt32(*pagination.Rows.GetByIndex(2))
|
logType = q5.ToInt32(pagination.Rows.GetByIndex(2))
|
||||||
content = q5.ToString(*pagination.Rows.GetByIndex(3))
|
content = q5.ToString(pagination.Rows.GetByIndex(3))
|
||||||
|
|
||||||
guildLog := &GuildLog{
|
guildLog := &GuildLog{
|
||||||
GuildId: guildId,
|
GuildId: guildId,
|
||||||
@ -414,11 +414,11 @@ func (gm *GuildMgr) findGuildIdsByName(sinceId int64, name string, cb func(err e
|
|||||||
lastId := sinceId
|
lastId := sinceId
|
||||||
ids := make([]int64, 0, MaxSearchResults)
|
ids := make([]int64, 0, MaxSearchResults)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
autoId := q5.ToInt64(*rows.GetByIndex(0))
|
autoId := q5.ToInt64(rows.GetByIndex(0))
|
||||||
if lastId < autoId {
|
if lastId < autoId {
|
||||||
lastId = autoId
|
lastId = autoId
|
||||||
}
|
}
|
||||||
guildId := q5.ToInt64(*rows.GetByIndex(1))
|
guildId := q5.ToInt64(rows.GetByIndex(1))
|
||||||
ids = append(ids, guildId)
|
ids = append(ids, guildId)
|
||||||
}
|
}
|
||||||
cb(nil, lastId, ids)
|
cb(nil, lastId, ids)
|
||||||
|
@ -49,7 +49,7 @@ func (this *PlayerMgr) init() {
|
|||||||
f5.GetSysLog().Info(
|
f5.GetSysLog().Info(
|
||||||
"%s:%s",
|
"%s:%s",
|
||||||
columns[i],
|
columns[i],
|
||||||
*dataSet.GetByName(columns[i]))
|
dataSet.GetByName(columns[i]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user