This commit is contained in:
aozhiwei 2024-04-02 08:51:31 +08:00
parent 48a33b5028
commit e00021c79e
2 changed files with 55 additions and 0 deletions

View File

@ -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)

View File

@ -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