This commit is contained in:
aozhiwei 2024-04-09 16:13:37 +08:00
parent 7c4c8e61dd
commit c57b0e8eb7
2 changed files with 61 additions and 5 deletions

View File

@ -248,6 +248,26 @@ func (this *guild) asyncLeave(accountId string, cb func(int32, string)) {
})
}
func (this *guild) asyncUpdateOwner(owner string, cb func(int32, string)) {
f5.GetJsStyleDb().Update(
constant.FRIEND_DB,
"t_guild",
[][]string{
{"owner_id", owner},
},
[][]string{
{"guild_id", this.guildId},
},
func (err error, lastInsertId int64, rowsAffected int64) {
if err != nil {
cb(500, "server internal error")
return
}
cb(0, "")
return
})
}
func newGuild() *guild {
p := new(guild)
p.idHash = make(map[string]*member)

View File

@ -563,6 +563,11 @@ func (this *guildMgr) AsyncSetGuildJob(accountId string, targetId string, guildJ
cb(0, "")
return;
}
owner := guild.getMember(accountId)
if owner == nil {
cb(0, "")
return;
}
member := guild.getMember(targetId)
if member == nil {
cb(0, "")
@ -580,11 +585,11 @@ func (this *guildMgr) AsyncSetGuildJob(accountId string, targetId string, guildJ
constant.FRIEND_DB,
"t_guild_member",
[][]string{
{"member_id", member.memberId},
{"guild_id", guild.guildId},
{"guild_job", q5.ToString(guildJob)},
},
[][]string{
{"guild_job", q5.ToString(guildJob)},
{"member_id", member.memberId},
{"guild_id", guild.guildId},
},
func (err error, lastInsertId int64, rowsAffected int64) {
if err != nil {
@ -593,10 +598,41 @@ func (this *guildMgr) AsyncSetGuildJob(accountId string, targetId string, guildJ
return
}
member.guildJob = guildJob
if guildJob == constant.GuildMemberLevelLeader {
f5.GetJsStyleDb().Update(
constant.FRIEND_DB,
"t_guild_member",
[][]string{
{"guild_job", q5.ToString(constant.GuildMemberLevelDefault)},
},
[][]string{
{"member_id", owner.memberId},
{"guild_id", guild.guildId},
},
func (err error, lastInsertId int64, rowsAffected int64) {
if err != nil {
task.SetFail()
cb(500, "")
return
}
owner.guildJob = constant.GuildMemberLevelDefault
guild.asyncUpdateOwner(member.memberId,
func (errCode int32, errMsg string) {
if err != nil {
task.SetFail()
cb(500, "")
return
}
task.SetSucc()
cb(0, "")
})
})
} else {
task.SetSucc()
cb(0, "")
}
})
})
}
func (this *guildMgr) AsyncKickout(accountId string, targetId string, cb func(int32, string)) {