This commit is contained in:
aozhiwei 2024-05-11 14:59:35 +08:00
parent ec3dbf148c
commit a626b16b5b

View File

@ -19,7 +19,7 @@ type dbEvent struct {
type userGroup struct { type userGroup struct {
groupId int64 groupId int64
userHash sync.Map userHash *sync.Map
} }
type mailMgr struct { type mailMgr struct {
@ -89,7 +89,7 @@ func (this *mailMgr) loadGroups() {
if this.getGroup(groupId) != nil { if this.getGroup(groupId) != nil {
panic(fmt.Sprintf("mailMgr.loadGroups group_id error")) panic(fmt.Sprintf("mailMgr.loadGroups group_id error"))
} }
p := new(userGroup) p := newUserGroup()
p.groupId = groupId p.groupId = groupId
this.addGroup(p) this.addGroup(p)
}, },
@ -456,7 +456,18 @@ func (this* mailMgr) procGroupUpdate(e *dbEvent) {
if err != nil { if err != nil {
return return
} }
groupId := q5.ToInt64(ds.GetByName("group_id"))
g := this.getGroup(groupId)
if g == nil {
p := newUserGroup()
p.groupId = groupId
this.addGroup(g)
} else {
g.userHash = new(sync.Map)
}
if ds.Next() { if ds.Next() {
memberId := ds.GetByName("member_id")
g.userHash.Store(memberId, q5.ToInt64(ds.GetByName("idx")))
return return
} else { } else {
panic(fmt.Sprintf("procGroupUpdate1 error:%s", err)); panic(fmt.Sprintf("procGroupUpdate1 error:%s", err));
@ -489,3 +500,9 @@ func (this* mailMgr) procGroupUpdate(e *dbEvent) {
} }
}) })
} }
func newUserGroup() *userGroup {
g := new(userGroup)
g.userHash = new(sync.Map)
return g
}