From 2e4eb3a61c4b39aa0b4ac71b7bf19daddf5dfbaa Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 13 Apr 2024 19:46:46 +0800 Subject: [PATCH] 1 --- README.md | 5 +++++ server/mailserver/mail/mail.go | 12 +----------- server/mailserver/mail/mailmgr.go | 18 +++++++----------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2c6b8618..fc3e2b33 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ SMLogin 用户群创建时间range(开始时间,结束时间) 用户群指定账号列表 +邮件 +增删改 +用户组 +增删改 + # 参考 https://gorm.io/zh_CN/docs/ diff --git a/server/mailserver/mail/mail.go b/server/mailserver/mail/mail.go index 79b4ac2c..4b6bb950 100644 --- a/server/mailserver/mail/mail.go +++ b/server/mailserver/mail/mail.go @@ -2,7 +2,6 @@ package mail import ( "f5" - "sync" //"main/common" //"main/constant" //"q5" @@ -15,7 +14,6 @@ type attachment struct { } type mail struct { - lock sync.Mutex mailId int64 mailType int32 subject string @@ -25,7 +23,7 @@ type mail struct { userRegStart int32 userRegEnd int32 attachments []*attachment - userGroups map[int64]*userGroup + userGroups []int64 reciver string } @@ -33,14 +31,6 @@ func (this *mail) init() { } -func (this *mail) Lock() { - this.lock.Lock() -} - -func (this *mail) Unlock() { - this.lock.Unlock() -} - func (this *mail) loadFromDb(ds *f5.DataSet) { } diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index f4838b40..3dbf4763 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -17,20 +17,17 @@ type groupMail struct { type userGroup struct { groupId int64 - mailHash map[int64]*mail userHash map[string]int64 } type mailMgr struct { - idHash map[int64]*mail - wholeMails map[int64]*mail + idHash sync.Map + wholeMails sync.Map groupMails [1024]*groupMail groupHash map[int64]*userGroup } func (this *mailMgr) Init() { - this.idHash = make(map[int64]*mail) - this.wholeMails = make(map[int64]*mail) this.groupHash = make(map[int64]*userGroup) this.loadMails() this.loadGroups() @@ -56,7 +53,7 @@ func (this *mailMgr) loadMails() { }) f5.GetSysLog().Info("mailMgr.loadMails end lastIdx:%d mailNum:%d", lastIdx, - len(this.idHash)) + q5.GetSyncMapSize(this.idHash)) } func (this *mailMgr) loadGroups() { @@ -71,7 +68,6 @@ func (this *mailMgr) loadGroups() { } p := new(userGroup) p.groupId = groupId - p.mailHash = make(map[int64]*mail) p.userHash = make(map[string]int64) this.groupHash[p.groupId] = p }, @@ -80,7 +76,7 @@ func (this *mailMgr) loadGroups() { }) f5.GetSysLog().Info("mailMgr.loadGroups end lastIdx:%d mailNum:%d", lastIdx, - len(this.idHash)) + q5.GetSyncMapSize(this.idHash)) } func (this *mailMgr) loadGroupMembers() { @@ -101,7 +97,7 @@ func (this *mailMgr) loadGroupMembers() { }) f5.GetSysLog().Info("mailMgr.loadGroupMembers end lastIdx:%d mailNum:%d", lastIdx, - len(this.idHash)) + q5.GetSyncMapSize(this.idHash)) } func (this *mailMgr) caGetMailList(hum common.Player, c *gin.Context) { @@ -129,9 +125,9 @@ func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) } func (this *mailMgr) addMail(m *mail) { - this.idHash[m.mailId] = m + this.idHash.Store(m.mailId, m) if m.isType(constant.MAIL_TYPE_ALL) { - this.wholeMails[m.mailId] = m + this.wholeMails.Store(m.mailId, m) } }