diff --git a/server/imserver_new/guild/guild.go b/server/imserver_new/guild/guild.go index ca83ddb7..2cd82a78 100644 --- a/server/imserver_new/guild/guild.go +++ b/server/imserver_new/guild/guild.go @@ -42,6 +42,10 @@ func (this *guild) loadFromDb(ds *f5.DataSet) { this.modifyTime = q5.ToInt32(ds.GetByName("modifytime")) } +func (this *guild) addMember(m *member) { + this.idHash[m.memberId] = m +} + func newGuild() *guild { p := new(guild) p.idHash = make(map[string]*member) diff --git a/server/imserver_new/guild/guildmgr.go b/server/imserver_new/guild/guildmgr.go index 04dbe786..1404d586 100644 --- a/server/imserver_new/guild/guildmgr.go +++ b/server/imserver_new/guild/guildmgr.go @@ -32,6 +32,9 @@ func (this *guildMgr) UnInit() { } func (this *guildMgr) loadFromDB() { +} + +func (this *guildMgr) loadGuild() { f5.GetSysLog().Info("friendMgr.loadFriendships begin") lastIdx := f5.GetJsStyleDb().SyncBatchLoadFullTable( constant.FRIEND_DB, @@ -50,17 +53,65 @@ func (this *guildMgr) loadFromDB() { len(this.nameHash)) } +func (this *guildMgr) loadGuildMember() { + f5.GetSysLog().Info("friendMgr.loadFriendships begin") + lastIdx := f5.GetJsStyleDb().SyncBatchLoadFullTable( + constant.FRIEND_DB, + "SELECT * FROM t_guild_member idx > %d AND deleted = 0", + func (ds *f5.DataSet) { + guildId := ds.GetByName("guild_id") + p := newMember() + g := this.internalGetGuildByGuildId(guildId) + if g != nil { + g.addMember(p) + } + }, + func (err error) { + panic(fmt.Sprintf("friendMgr.loadFriendships dberror:%s", err)) + }) + f5.GetSysLog().Info("friendMgr.loadFriendships end lastIdx:%d friendNum:%d blackNum:%d", + lastIdx, + len(this.idHash), + len(this.nameHash)) +} + func (this *guildMgr) isNameTooLong(name string, maxNum int) bool { return len(name) > maxNum } func (this *guildMgr) GetGuildByAccountId(accountId string) common.Guild { + return this.internalGetGuildByAccountId(accountId) +} + +func (this *guildMgr) GetGuildByGuildId(guildId string) common.Guild { + return this.internalGetGuildByGuildId(guildId) +} + +func (this *guildMgr) GetGuildByGuildName(guildName string) common.Guild { + return this.internalGetGuildByGuildName(guildName) +} + +func (this *guildMgr) internalGetGuildByAccountId(accountId string) *guild { if guild, ok := this.accountIdHash[accountId]; ok { return guild } return nil } +func (this *guildMgr) internalGetGuildByGuildId(guildId string) *guild { + if guild, ok := this.idHash[guildId]; ok { + return guild + } + return nil +} + +func (this *guildMgr) internalGetGuildByGuildName(guildName string) *guild { + if guild, ok := this.nameHash[guildName]; ok { + return guild + } + return nil +} + func (this *guildMgr) GetRecommendGuilds(string) []common.Guild { guilds := []common.Guild{} return guilds