1
This commit is contained in:
parent
e6a40c4f9e
commit
cc7b58078d
@ -86,7 +86,7 @@ type GuildMgr interface {
|
||||
AsyncCreateGuild(string, string, int32, string, func(int32, string, string))
|
||||
AsyncGetApplyList(int64, string, func(int32, string, int64, []string))
|
||||
AsyncApplyJoin(string, string, func(int32, string))
|
||||
AsyncAcceptApply(string, string, func(int32, string))
|
||||
AsyncAcceptApply(string, string, func(int32, string, string, string))
|
||||
AsyncRejectApply(string, string, func(int32, string))
|
||||
AsyncGetGuildRank(int32, func(int32, string, []string))
|
||||
AsyncGetRecommendGuild(int32, func(int32, string, []string))
|
||||
@ -98,6 +98,8 @@ type GuildMgr interface {
|
||||
AsyncSearch(int64, string, func(int32, string, int64, []string))
|
||||
AsyncGetGuildLogs(string, string, func(int32, string))
|
||||
AsyncUpdateGuild(string, map[int32]string, func(int32, string))
|
||||
|
||||
NotifyGuildMsg(string, proto.Message)
|
||||
}
|
||||
|
||||
type CacheMgr interface {
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"mt"
|
||||
"strings"
|
||||
. "main/global"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type guildMgr struct {
|
||||
@ -339,20 +340,21 @@ func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(i
|
||||
}
|
||||
|
||||
func (this *guildMgr) asyncAcceptApplyTask(task *f5.LockAsyncTask, guild *guild,
|
||||
accountId string, targetId string, cb func(int32, string)) {
|
||||
accountId string, targetId string,
|
||||
cb func(int32, string, string, string)) {
|
||||
if !guild.isOwner(accountId) {
|
||||
task.SetFail()
|
||||
cb(1, "")
|
||||
cb(1, "", "", "")
|
||||
return
|
||||
}
|
||||
if accountId == targetId {
|
||||
task.SetFail()
|
||||
cb(1, "")
|
||||
cb(1, "", "", "")
|
||||
return
|
||||
}
|
||||
if this.internalGetMemberByAccountId(targetId) != nil {
|
||||
task.SetFail()
|
||||
cb(1, "")
|
||||
cb(1, "", "", "")
|
||||
return
|
||||
}
|
||||
nowTime := f5.GetApp().GetNowSeconds()
|
||||
@ -360,7 +362,7 @@ func (this *guildMgr) asyncAcceptApplyTask(task *f5.LockAsyncTask, guild *guild,
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
if err != nil {
|
||||
task.SetFail()
|
||||
cb(500, "server internal error")
|
||||
cb(500, "server internal error", "", "")
|
||||
return
|
||||
}
|
||||
m := newMember()
|
||||
@ -370,16 +372,17 @@ func (this *guildMgr) asyncAcceptApplyTask(task *f5.LockAsyncTask, guild *guild,
|
||||
model.GuildApply.SetStatus(guild.guildId, targetId, constant.GUILD_APPLY_STATUS_ACCEPT,
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
task.SetSucc()
|
||||
cb(0, "")
|
||||
cb(0, "", guild.guildId, guild.guildName)
|
||||
return
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncAcceptApply(accountId string, targetId string, cb func(int32, string)) {
|
||||
func (this *guildMgr) AsyncAcceptApply(accountId string, targetId string,
|
||||
cb func(int32, string, string, string)) {
|
||||
guild := this.internalGetGuildByAccountId(accountId)
|
||||
if guild == nil {
|
||||
cb(0, "")
|
||||
cb(0, "", guild.guildId, guild.guildName)
|
||||
return;
|
||||
}
|
||||
f5.NewLockAsyncTask([][]string{
|
||||
@ -711,6 +714,18 @@ func (this *guildMgr) AsyncUpdateGuild(accountId string, kv map[int32]string, cb
|
||||
})
|
||||
}
|
||||
|
||||
func (this *guildMgr) NotifyGuildMsg(guildId string, msg proto.Message) {
|
||||
g := this.internalGetGuildByGuildId(guildId)
|
||||
g.traverseMembers(
|
||||
func (m *member) bool {
|
||||
hum := GetPlayerMgr().GetPlayerByAccountId(m.memberId)
|
||||
if hum != nil {
|
||||
hum.SendMsg(msg)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func (this *guildMgr) AsyncGetGuildRank(num int32, cb func(int32, string, []string)) {
|
||||
guildIds := []string{}
|
||||
for _, m := range(this.guildRankList) {
|
||||
|
@ -515,12 +515,30 @@ func (this *player) CMApprove(hdr *f5.MsgHdr, msg *cs.CMApprove) {
|
||||
GetGuildMgr().AsyncAcceptApply(
|
||||
this.GetAccountId(),
|
||||
msg.GetApplicantAccountId(),
|
||||
func (errCode int32, errMsg string) {
|
||||
func (errCode int32, errMsg string, guildId string, guildName string) {
|
||||
if errCode != 0 {
|
||||
this.SendMsg(rspMsg.Err(errCode, errMsg))
|
||||
return
|
||||
}
|
||||
this.SendMsg(rspMsg)
|
||||
{
|
||||
pbGuilds := []*cs.MFGuildMember{}
|
||||
GetCacheMgr().AsyncGetUsersAndFillMFGuildMember(
|
||||
[]string{
|
||||
msg.GetApplicantAccountId(),
|
||||
},
|
||||
&pbGuilds,
|
||||
func (errCode int32, errMsg string) {
|
||||
if errCode == 0 && len(pbGuilds) > 0 {
|
||||
notifyMsg := new(cs.SMApproveJoinGuildNotify)
|
||||
notifyMsg.GuildId = proto.Int64(q5.ToInt64(guildId))
|
||||
notifyMsg.Name = proto.String(guildName)
|
||||
notifyMsg.AccountId = proto.String(pbGuilds[0].GetAccountId())
|
||||
notifyMsg.Username = proto.String(pbGuilds[0].GetUsername())
|
||||
GetGuildMgr().NotifyGuildMsg(guildId, notifyMsg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user