127 lines
2.8 KiB
Go
127 lines
2.8 KiB
Go
package mail
|
|
|
|
import (
|
|
"q5"
|
|
"f5"
|
|
"main/common"
|
|
"main/constant"
|
|
"sync"
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type userMail struct {
|
|
lock sync.Mutex
|
|
userMailHash map[string]map[int64]*mail
|
|
}
|
|
|
|
type userGroup struct {
|
|
mailHash map[int64]*mail
|
|
userHash map[string]int32
|
|
}
|
|
|
|
type mailMgr struct {
|
|
idHash map[int64]*mail
|
|
allMails map[int64]*mail
|
|
userMailArr [1024]*userMail
|
|
groupHash map[int64]*userGroup
|
|
}
|
|
|
|
func (this *mailMgr) Init() {
|
|
this.idHash = make(map[int64]*mail)
|
|
this.allMails = make(map[int64]*mail)
|
|
this.groupHash = make(map[int64]*userGroup)
|
|
this.loadMails()
|
|
this.loadGroups()
|
|
this.loadGroupMembers()
|
|
}
|
|
|
|
func (this *mailMgr) UnInit() {
|
|
}
|
|
|
|
func (this *mailMgr) loadMails() {
|
|
f5.GetSysLog().Info("mailMgr.loadMails begin")
|
|
nowTime := f5.GetApp().GetNowSeconds()
|
|
lastIdx := f5.GetJsStyleDb().SyncBatchLoadFullTable(
|
|
constant.MAIL_DB,
|
|
"SELECT * FROM t_mail WHERE idx > %d AND deleted = 0 AND expiretime > " + q5.ToString(nowTime),
|
|
func (ds *f5.DataSet) {
|
|
p := newMail()
|
|
p.loadFromDb(ds)
|
|
this.addMail(p)
|
|
},
|
|
func (err error) {
|
|
panic(fmt.Sprintf("mailMgr.loadMails dberror:%s", err))
|
|
})
|
|
f5.GetSysLog().Info("mailMgr.loadMails end lastIdx:%d mailNum:%d",
|
|
lastIdx,
|
|
len(this.idHash))
|
|
}
|
|
|
|
func (this *mailMgr) loadGroups() {
|
|
f5.GetSysLog().Info("mailMgr.loadGroups begin")
|
|
lastIdx := f5.GetJsStyleDb().SyncBatchLoadFullTable(
|
|
constant.MAIL_DB,
|
|
"SELECT * FROM t_group WHERE idx > %d AND deleted = 0",
|
|
func (ds *f5.DataSet) {
|
|
p := newMail()
|
|
p.loadFromDb(ds)
|
|
this.addMail(p)
|
|
},
|
|
func (err error) {
|
|
panic(fmt.Sprintf("mailMgr.loadGroups dberror:%s", err))
|
|
})
|
|
f5.GetSysLog().Info("mailMgr.loadGroups end lastIdx:%d mailNum:%d",
|
|
lastIdx,
|
|
len(this.idHash))
|
|
}
|
|
|
|
func (this *mailMgr) loadGroupMembers() {
|
|
f5.GetSysLog().Info("mailMgr.loadGroupMembers begin")
|
|
lastIdx := f5.GetJsStyleDb().SyncBatchLoadFullTable(
|
|
constant.MAIL_DB,
|
|
"SELECT * FROM t_member WHERE idx > %d AND deleted = 0",
|
|
func (ds *f5.DataSet) {
|
|
p := newMail()
|
|
p.loadFromDb(ds)
|
|
this.addMail(p)
|
|
},
|
|
func (err error) {
|
|
panic(fmt.Sprintf("mailMgr.loadGroupMembers dberror:%s", err))
|
|
})
|
|
f5.GetSysLog().Info("mailMgr.loadGroupMembers end lastIdx:%d mailNum:%d",
|
|
lastIdx,
|
|
len(this.idHash))
|
|
}
|
|
|
|
func (this *mailMgr) caGetMailList(hum common.Player, c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (this *mailMgr) caMarkMail(hum common.Player, c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (this *mailMgr) caGetUnreadMailCnt(hum common.Player, c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (this *mailMgr) caGetAttachment(hum common.Player, c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (this *mailMgr) caDeleteMails(hum common.Player, c *gin.Context) {
|
|
|
|
}
|
|
|
|
func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) {
|
|
|
|
}
|
|
|
|
func (this *mailMgr) addMail(m *mail) {
|
|
this.idHash[m.mailId] = m
|
|
if m.isType(constant.MAIL_TYPE_ALL) {
|
|
this.allMails[m.mailId] = m
|
|
}
|
|
}
|