This commit is contained in:
殷勇 2023-09-25 16:50:04 +08:00
parent b273f36ed2
commit 502d6f02b4
2 changed files with 7 additions and 7 deletions

View File

@ -7,12 +7,12 @@ import (
"q5"
)
var tableNames = make(map[string]string)
var tableName = make(map[string]string)
func (cm *CacheMgr) LoadFromDB() {
tableNames["user"] = fmt.Sprintf("%s.t_user", mt.Table.GameDb.GetById(0).GetDatabase())
tableNames["friendships"] = fmt.Sprintf("%s.t_friend_ships", mt.Table.FriendDb.GetById(0).GetDatabase())
tableNames["guild_member"] = fmt.Sprintf("%s.t_guild_members", mt.Table.FriendDb.GetById(0).GetDatabase())
tableName["user"] = fmt.Sprintf("%s.t_user", mt.Table.GameDb.GetById(0).GetDatabase())
tableName["friendships"] = fmt.Sprintf("%s.t_friend_ships", mt.Table.FriendDb.GetById(0).GetDatabase())
tableName["guild_member"] = fmt.Sprintf("%s.t_guild_members", mt.Table.FriendDb.GetById(0).GetDatabase())
// 加载所有好友信息
cm.loadAllFriendUserProfile()
// 加载所有工会成员信息
@ -21,13 +21,13 @@ func (cm *CacheMgr) LoadFromDB() {
// TODO 重加载数据1000 迭代
func (cm *CacheMgr) loadAllFriendUserProfile() {
sql := fmt.Sprintf("SELECT account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM ( SELECT account1_id AS account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM %s AS fs JOIN %s AS u ON fs.account1_id = u.account_id UNION SELECT account2_id AS account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM %s AS fs JOIN %s AS u ON fs.account2_id = u.account_id) AS friend_info_table;", tableNames["friendships"], tableNames["user"], tableNames["friendships"], tableNames["user"])
sql := fmt.Sprintf("SELECT account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM ( SELECT account1_id AS account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM %s AS fs JOIN %s AS u ON fs.account1_id = u.account_id UNION SELECT account2_id AS account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM %s AS fs JOIN %s AS u ON fs.account2_id = u.account_id) AS friend_info_table;", tableName["friendships"], tableName["user"], tableName["friendships"], tableName["user"])
cm.loadUsersProfile(sql)
}
// loadGuildFromDB 加载公会成员信息
func (cm *CacheMgr) loadAllGuildUserProfile() {
sql := fmt.Sprintf("select a.account_id, a.name, a.head_id, a.head_frame, a.star_num, a.`rank`, a.last_login_time from %s a,%s b where a.account_id = b.account_id", tableNames["user"], tableNames["guild_member"])
sql := fmt.Sprintf("select a.account_id, a.name, a.head_id, a.head_frame, a.star_num, a.`rank`, a.last_login_time from %s a,%s b where a.account_id = b.account_id", tableName["user"], tableName["guild_member"])
cm.loadUsersProfile(sql)
}

View File

@ -138,7 +138,7 @@ func (this *PlayerMgr) CMLoginResult(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.Htt
friendMgr.LoadUser(accountId)
serverInfo := proto.String(mt.Table.IMCluster.GetServerInfo())
f5.GetSysLog().Info("ServerInfo:%s", serverInfo)
f5.GetSysLog().Info("ServerInfo:%s", *serverInfo)
rspMsg := &cs.SMLogin{}
rspMsg.ServerInfo = serverInfo