diff --git a/server/mailserver/common/types.go b/server/mailserver/common/types.go index fd007926..23a1505b 100644 --- a/server/mailserver/common/types.go +++ b/server/mailserver/common/types.go @@ -8,14 +8,37 @@ type App interface { } type Player interface { + Lock() + UnLock() GetAccountId() string GetRegisterTime() int32 - IsUnreadMail(int64) bool - IsDeletedMail(int64) bool + FillMailList(mailList *[]MailDto) + ReadMails(mailIds []int64) + GetUnreadMailCnt() int32 + GetMailById(mailId int64) *MailDto + GetAttachments(mailIds []int64) + DeleteMails(mailIds []int64) + IsDeletedMail(mailId int64) + IsReadedMail(mailId int64) } type PlayerMgr interface{} -type Mail interface{} + +type AttachmentDto struct { + ItemId int32 `json:"itemid"` + ItemNum int32 `json:"itemnum"` +} + +type MailDto struct { + MailId string `json:"mailid"` + Subject string `json:"subject"` + Content string `json:"content"` + Flags int32 `json:"flags"` + SendTime int32 `json:"sendtime"` + ExpireTime int32 `json:"expiretime""` + Attachments []AttachmentDto `json:"attachments""` +} + type MailMgr interface{} type ControllerMgr interface{} diff --git a/server/mailserver/controller/mail.go b/server/mailserver/controller/mail.go index bb68a653..218a4417 100644 --- a/server/mailserver/controller/mail.go +++ b/server/mailserver/controller/mail.go @@ -11,6 +11,7 @@ func mail_getMailList(c *gin.Context) { var msg struct { ErrCode int32 `json:"errcode"` ErrMsg string `json:"errmsg"` + MailList []common.MailDto `json:"maillist""` } msg.ErrCode = 0 msg.ErrMsg = hum.GetAccountId() diff --git a/server/mailserver/mail/mail.go b/server/mailserver/mail/mail.go index 83f98421..1b404225 100644 --- a/server/mailserver/mail/mail.go +++ b/server/mailserver/mail/mail.go @@ -1,11 +1,10 @@ package mail import ( - "main/common" - "main/constant" - "q5" - "strings" - "time" + //"main/common" + //"main/constant" + //"q5" + //"strings" ) type Attachment struct { @@ -57,6 +56,7 @@ func NewMail() *Mail { return m } +/* func (m *Mail) ParseAttachments(attachmentsStr string) { if len(attachmentsStr) <= 0 { m.ATT = make([]*Attachment, 0) @@ -80,32 +80,4 @@ func (m *Mail) ParseAttachments(attachmentsStr string) { m.ATT = append(m.ATT, attachment) } } - -func (m *Mail) FillMutableXObject() {} -func (m *Mail) GMFillMutableXObject() {} - -func (m *Mail) HasAttachment() bool { - return len(m.ATT) > 0 -} - -func (m *Mail) IsReadableMail(accountObj common.Player) bool { - if m.MailType == constant.MAIL_TYPE_GROUP { - if m.UserType == 1 { - // 只有在邮件发送时间之前注册的用户可以读 - if accountObj.GetRegisterTime() > m.SendTime { - return false - } - } else if m.UserType == 2 { - // 只有在邮件发送时间之后注册的用户可以读 - if accountObj.GetRegisterTime() < m.SendTime { - return false - } - } - } - nowUnixSec := int32(time.Now().Unix()) - if m.ExpireTime > nowUnixSec && m.SendTime <= nowUnixSec && !accountObj.IsDeletedMail(m.MailId) { - return true - } - - return false -} +*/ diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index bceaf48f..f5163757 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -184,6 +184,7 @@ func (this *MailMgr) GetGMMailList(gameId int) []*GMMail { return resMailList } +/* func (this *MailMgr) GetMailList(player common.Player) []*Mail { gameMailList := this.gameMailHash[constant.GAMEID] playerMailList := this.playerMailHash[player.GetAccountId()] @@ -230,32 +231,4 @@ func (this *MailMgr) GetMailList(player common.Player) []*Mail { } return resMailList } - -func (this *MailMgr) markMail(accountObj common.Player) { -} - -func (this *MailMgr) GetUnreadMailCount(accountObj common.Player) int { - mailCnt := 0 - if gameMails, ok := this.gameMailHash[constant.GAMEID]; ok { - for _, mailObj := range gameMails { - if mailObj.IsReadableMail(accountObj) { - mailCnt++ - } - } - } - if playerMails, ok := this.playerMailHash[accountObj.GetAccountId()]; ok { - for _, mailObj := range playerMails { - if mailObj.IsReadableMail(accountObj) { - mailCnt++ - } - } - } - - return mailCnt -} - -func (this *MailMgr) getAttachment(accountObj common.Player) { -} - -func (this *MailMgr) deleteMails(accountObj common.Player) { -} +*/ diff --git a/server/mailserver/player/player.go b/server/mailserver/player/player.go index b1f8e4b2..ffdeb6c7 100644 --- a/server/mailserver/player/player.go +++ b/server/mailserver/player/player.go @@ -109,31 +109,6 @@ func (p *Player) DeleteMails(mailIds string) { p.MarkDirty() } -func (p *Player) AddToReadList() {} - -func (p *Player) GetAttachment(mailIds string) []interface{} { - attachments := make([]interface{}, 0) - mailMgrPtr := global.GetMailMgr().(*mail.MailMgr) - mailIdStrings := strings.Split(mailIds, ",") - for _, _mailId := range mailIdStrings { - if len(_mailId) <= 0 { - continue - } - mailId := q5.ToInt64(_mailId) - mailObj := mailMgrPtr.GetMail(mailId) - if mailObj == nil || !mailObj.HasAttachment() || p.IsDeletedMail(mailId) { - continue - } - - for _, mailATT := range mailObj.ATT { - attachments = append(attachments, mailATT) - } - p.DeleteMails(_mailId) - } - - return attachments -} - /* func (p *Player) Deserialize(accountPB *ss.MFAccountData) { var nextDaySec int32 = 3600 * 24