diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index 22c5563f..bec403b9 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -68,7 +68,7 @@ type FriendMgr interface { } type Guild interface { - GetGuildId() int64 + GetGuildId() string } type GuildMember interface { diff --git a/server/imserver_new/guild/guild.go b/server/imserver_new/guild/guild.go index 20b616f2..eae00a2d 100644 --- a/server/imserver_new/guild/guild.go +++ b/server/imserver_new/guild/guild.go @@ -5,4 +5,19 @@ import ( ) type guild struct { + guildId string + guildName string + ownerId string + creatorId string + badge int32 + notice string + joinCondType int32 + joinCondVal int32 + maxMemberNum int32 + createTime int32 + modifyTime int32 +} + +func (this *guild) GetGuildId() string { + return this.guildId } diff --git a/server/imserver_new/guild/guildmgr.go b/server/imserver_new/guild/guildmgr.go index 6f5c36f2..c4169c8b 100644 --- a/server/imserver_new/guild/guildmgr.go +++ b/server/imserver_new/guild/guildmgr.go @@ -12,14 +12,15 @@ const ( ) type guildMgr struct { - /* - guilds map[int64]*Guild // 公会ID -> 公会 - guildLogs map[int64][]*GuildLog // 公会ID -> []公会日志列表 - userGuilds map[string]int64 // accountId -> 公会ID - loadedFlags int64*/ + idHash map[string]*guild + nameHash map[string]*guild + accountIdHash map[string]*guild } func (this *guildMgr) Init() { + this.idHash = make(map[string]*guild) + this.nameHash = make(map[string]*guild) + this.accountIdHash = make(map[string]*guild) } func (this *guildMgr) UnInit() { @@ -29,7 +30,10 @@ func (this *guildMgr) isNameTooLong(name string, maxNum int) bool { return len(name) > maxNum } -func (this *guildMgr) GetGuildByAccountId(string) common.Guild { +func (this *guildMgr) GetGuildByAccountId(accountId string) common.Guild { + if guild, ok := this.accountIdHash[accountId]; ok { + return guild + } return nil }