This commit is contained in:
aozhiwei 2024-04-04 21:36:29 +08:00
parent d81a77c3c3
commit 7a57eb9a7b
2 changed files with 11 additions and 6 deletions

View File

@ -38,7 +38,8 @@ const (
const ( const (
MEMBER_LOCK_KEY = "member:" MEMBER_LOCK_KEY = "member:"
GUILD_LOCK_KEY = "guild:" GUILD_ID_LOCK_KEY = "guild_id:"
GUILD_NAME_LOCK_KEY = "guild_name:"
) )
// im server chat // im server chat

View File

@ -153,7 +153,9 @@ func (this* guildMgr) removeUsingName(name string) {
delete(this.usingNameHash, name) delete(this.usingNameHash, name)
} }
func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask, accountId string, avatar int32, name string, func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask,
guildId string,
accountId string, avatar int32, name string,
cb func(int32, string, int64)) { cb func(int32, string, int64)) {
if this.internalGetGuildByAccountId(accountId) != nil { if this.internalGetGuildByAccountId(accountId) != nil {
task.SetFail() task.SetFail()
@ -171,7 +173,6 @@ func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask, accountId string,
return return
} }
this.addUsingName(name) this.addUsingName(name)
guildId := q5.ToString(f5.GetApp().NewNodeUuid())
nowTime := f5.GetApp().GetNowSeconds() nowTime := f5.GetApp().GetNowSeconds()
f5.GetJsStyleDb().Insert( f5.GetJsStyleDb().Insert(
constant.FRIEND_DB, constant.FRIEND_DB,
@ -236,12 +237,15 @@ func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask, accountId string,
func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string, func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string,
cb func(int32, string, int64)) { cb func(int32, string, int64)) {
guildId := q5.ToString(f5.GetApp().NewNodeUuid())
f5.GetApp().AsyncLock([][]string{ f5.GetApp().AsyncLock([][]string{
{constant.MEMBER_LOCK_KEY, accountId}, {constant.MEMBER_LOCK_KEY, accountId},
{constant.GUILD_ID_LOCK_KEY, guildId},
{constant.GUILD_NAME_LOCK_KEY, name},
}, },
f5.NewAsyncTask( f5.NewAsyncTask(
func (task *f5.AsyncTask) { func (task *f5.AsyncTask) {
this.asyncCreateGuildTask(task, accountId, avatar, name, cb) this.asyncCreateGuildTask(task, guildId, accountId, avatar, name, cb)
})) }))
} }
@ -363,7 +367,7 @@ func (this *guildMgr) AsyncAcceptApply(accountId string, targetId string, cb fun
f5.GetApp().AsyncLock([][]string{ f5.GetApp().AsyncLock([][]string{
{constant.MEMBER_LOCK_KEY, accountId}, {constant.MEMBER_LOCK_KEY, accountId},
{constant.MEMBER_LOCK_KEY, targetId}, {constant.MEMBER_LOCK_KEY, targetId},
{constant.GUILD_LOCK_KEY, guild.guildId}, {constant.GUILD_ID_LOCK_KEY, guild.guildId},
}, },
f5.NewAsyncTask( f5.NewAsyncTask(
func (task *f5.AsyncTask) { func (task *f5.AsyncTask) {