This commit is contained in:
aozhiwei 2024-04-15 09:00:48 +08:00
parent 8e487c9898
commit 32c16fa7c8
3 changed files with 58 additions and 5 deletions

View File

@ -32,11 +32,19 @@ type Player interface {
UnLock() UnLock()
GetHashCode() uint32 GetHashCode() uint32
GetAccountId() string GetAccountId() string
MarkMails([]Mail)
GetAttachment([]Mail)
DeleteMails([]Mail)
} }
type PlayerMgr interface{ type PlayerMgr interface {
GetPlayerByAccountId() Player GetPlayerByAccountId() Player
} }
type Mail interface {
GetMailId() int64
}
type MailMgr interface{ type MailMgr interface{
} }

View File

@ -44,6 +44,10 @@ func (this *mail) isValid(hum common.Player) bool {
return true return true
} }
func (this *mail) GetMailId() int64 {
return this.mailId
}
func (this *mail) fillMailDto(mailDto *common.MailDto) bool { func (this *mail) fillMailDto(mailDto *common.MailDto) bool {
return true return true
} }

View File

@ -116,12 +116,19 @@ func (this *mailMgr) caGetMailList(hum common.Player, c *gin.Context) {
func (this *mailMgr) caMarkMail(hum common.Player, c *gin.Context) { func (this *mailMgr) caMarkMail(hum common.Player, c *gin.Context) {
mailIds := q5.StrSplit(c.DefaultQuery("mail_ids", ""), ",") mailIds := q5.StrSplit(c.DefaultQuery("mail_ids", ""), ",")
mails := []common.Mail{}
for _, str := range(mailIds) { for _, str := range(mailIds) {
m := this.getMail(str) m := this.getMail(str)
if m != nil { if m != nil {
q5.AppendSlice(&mails, m)
} }
} }
hum.MarkMails(mails)
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{}
c.JSON(200, rspObj)
} }
func (this *mailMgr) caGetUnreadMailCnt(hum common.Player, c *gin.Context) { func (this *mailMgr) caGetUnreadMailCnt(hum common.Player, c *gin.Context) {
@ -129,11 +136,37 @@ func (this *mailMgr) caGetUnreadMailCnt(hum common.Player, c *gin.Context) {
} }
func (this *mailMgr) caGetAttachment(hum common.Player, c *gin.Context) { func (this *mailMgr) caGetAttachment(hum common.Player, c *gin.Context) {
mailIds := q5.StrSplit(c.DefaultQuery("mail_ids", ""), ",")
mails := []common.Mail{}
for _, str := range(mailIds) {
m := this.getMail(str)
if m != nil {
q5.AppendSlice(&mails, m)
}
}
hum.GetAttachment(mails)
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{}
c.JSON(200, rspObj)
} }
func (this *mailMgr) caDeleteMails(hum common.Player, c *gin.Context) { func (this *mailMgr) caDeleteMails(hum common.Player, c *gin.Context) {
mailIds := q5.StrSplit(c.DefaultQuery("mail_ids", ""), ",")
mails := []common.Mail{}
for _, str := range(mailIds) {
m := this.getMail(str)
if m != nil {
q5.AppendSlice(&mails, m)
}
}
hum.DeleteMails(mails)
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{}
c.JSON(200, rspObj)
} }
func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) { func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) {
@ -190,7 +223,15 @@ func (this *mailMgr) getGroup(groupId int64) *userGroup {
} }
} }
func (this *mailMgr) getMail(mailId string) *mail { func (this *mailMgr) getMail(mailId string) common.Mail {
if m := this.internalGetMail(mailId); m != nil {
return m
} else {
return nil
}
}
func (this *mailMgr) internalGetMail(mailId string) *mail {
if p, ok := this.idHash.Load(mailId); ok { if p, ok := this.idHash.Load(mailId); ok {
return p.(*mail) return p.(*mail)
} else { } else {