1
This commit is contained in:
parent
48139bfac4
commit
6cce01860c
@ -5,6 +5,7 @@ import (
|
||||
"f5"
|
||||
"cs"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"main/constant"
|
||||
. "main/global"
|
||||
)
|
||||
|
||||
@ -56,6 +57,14 @@ func (this *guild) getMember(accountId string) *member {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *guild) traverseMembers(cb func(*member) bool) {
|
||||
for _, m := range(this.idHash) {
|
||||
if !cb(m) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *guild) isOwner(accountId string) bool {
|
||||
if this.getMember(accountId) == nil {
|
||||
return false
|
||||
@ -63,6 +72,44 @@ func (this *guild) isOwner(accountId string) bool {
|
||||
return this.ownerId == accountId
|
||||
}
|
||||
|
||||
func (this *guild) disband() {
|
||||
{
|
||||
f5.GetJsStyleDb().Update(
|
||||
constant.FRIEND_DB,
|
||||
"t_guild_member",
|
||||
[][]string{
|
||||
{"deleted", "1"},
|
||||
},
|
||||
[][]string{
|
||||
{"guild_id", this.guildId},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
})
|
||||
}
|
||||
{
|
||||
f5.GetJsStyleDb().Update(
|
||||
constant.FRIEND_DB,
|
||||
"t_guild_apply",
|
||||
[][]string{
|
||||
{"deleted", "1"},
|
||||
},
|
||||
[][]string{
|
||||
{"guild_id", this.guildId},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
})
|
||||
}
|
||||
{
|
||||
delete(_guildMgr.idHash, this.guildId)
|
||||
delete(_guildMgr.nameHash, this.guildName)
|
||||
this.traverseMembers(
|
||||
func (m *member) bool {
|
||||
delete(_guildMgr.memberIdHash, m.memberId)
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (this *guild) AsyncFillMFGuild(pbGuild *cs.MFGuild, cb func(int32, string)) {
|
||||
pbGuild.AutoId = proto.Int64(0)
|
||||
pbGuild.GuildId = proto.Int64(q5.ToInt64(this.guildId))
|
||||
|
@ -469,7 +469,64 @@ func (this *guildMgr) AsyncKickout(accountId string, targetId string, cb func(in
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncDisband(accountId string, cb func(int32, string, []string)) {
|
||||
|
||||
members := []string{}
|
||||
keys := [][]string{}
|
||||
{
|
||||
guild := this.internalGetGuildByAccountId(accountId)
|
||||
if guild == nil {
|
||||
cb(0, "", members)
|
||||
return
|
||||
}
|
||||
if !guild.isOwner(accountId) {
|
||||
cb(1, "Disband only leader perm", members)
|
||||
return
|
||||
}
|
||||
keys = [][]string{
|
||||
{constant.GUILD_ID_LOCK_KEY, guild.guildId},
|
||||
{constant.GUILD_NAME_LOCK_KEY, guild.guildName},
|
||||
};
|
||||
guild.traverseMembers(
|
||||
func (m *member) bool {
|
||||
q5.AppendSlice(&keys, []string{constant.GUILD_MEMBER_LOCK_KEY, m.memberId})
|
||||
q5.AppendSlice(&members, m.memberId)
|
||||
return true
|
||||
})
|
||||
}
|
||||
f5.NewLockAsyncTask(
|
||||
keys,
|
||||
func (task *f5.LockAsyncTask) {
|
||||
guild := this.internalGetGuildByAccountId(accountId)
|
||||
members := []string{}
|
||||
if guild == nil {
|
||||
task.SetSucc()
|
||||
cb(0, "", members)
|
||||
return
|
||||
}
|
||||
if !guild.isOwner(accountId) {
|
||||
task.SetFail()
|
||||
cb(1, "Disband only leader perm", members)
|
||||
return
|
||||
}
|
||||
f5.GetJsStyleDb().Update(
|
||||
constant.FRIEND_DB,
|
||||
"t_guild",
|
||||
[][]string{
|
||||
{"deleted", "1"},
|
||||
},
|
||||
[][]string{
|
||||
{"guild_id", guild.guildId},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
if err != nil {
|
||||
task.SetFail()
|
||||
cb(500, "server internal error", members)
|
||||
return
|
||||
}
|
||||
task.SetSucc()
|
||||
cb(0, "", members)
|
||||
return
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncSetNotice(string, string, func(int32, string)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user