save
This commit is contained in:
parent
b0f7b10a02
commit
74d6888f96
@ -20,7 +20,7 @@ type getMailsReq struct {
|
|||||||
func (api *MailApi) GetMailList(c *gin.Context) {
|
func (api *MailApi) GetMailList(c *gin.Context) {
|
||||||
var req getMailsReq
|
var req getMailsReq
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ func (api *MailApi) GetMailList(c *gin.Context) {
|
|||||||
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
||||||
if accountObj == nil {
|
if accountObj == nil {
|
||||||
err := fmt.Errorf("account is null")
|
err := fmt.Errorf("account is null")
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commonPlayer := (common.Player)(accountObj)
|
commonPlayer := (common.Player)(accountObj)
|
||||||
@ -51,18 +51,18 @@ type markMailReq struct {
|
|||||||
func (api *MailApi) MarkMail(c *gin.Context) {
|
func (api *MailApi) MarkMail(c *gin.Context) {
|
||||||
var req markMailReq
|
var req markMailReq
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if req.Flag != "read" {
|
if req.Flag != "read" {
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, fmt.Errorf("flag is not `read`")))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, fmt.Errorf("flag is not `read`")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
||||||
if accountObj == nil {
|
if accountObj == nil {
|
||||||
err := fmt.Errorf("account is null")
|
err := fmt.Errorf("account is null")
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
accountObj.MarkMail(req.MailIds)
|
accountObj.MarkMail(req.MailIds)
|
||||||
@ -82,14 +82,14 @@ type getUnreadMailCountReq struct {
|
|||||||
func (api *MailApi) GetUnreadMailCount(c *gin.Context) {
|
func (api *MailApi) GetUnreadMailCount(c *gin.Context) {
|
||||||
var req getUnreadMailCountReq
|
var req getUnreadMailCountReq
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
||||||
if accountObj == nil {
|
if accountObj == nil {
|
||||||
err := fmt.Errorf("account is null")
|
err := fmt.Errorf("account is null")
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commonPlayer := (common.Player)(accountObj)
|
commonPlayer := (common.Player)(accountObj)
|
||||||
@ -112,21 +112,21 @@ type getMailAttachmentReq struct {
|
|||||||
func (api *MailApi) GetMailAttachment(c *gin.Context) {
|
func (api *MailApi) GetMailAttachment(c *gin.Context) {
|
||||||
var req getMailAttachmentReq
|
var req getMailAttachmentReq
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
||||||
if accountObj == nil {
|
if accountObj == nil {
|
||||||
err := fmt.Errorf("account is null")
|
err := fmt.Errorf("account is null")
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
att := accountObj.GetAttachment(req.MailIds)
|
att := accountObj.GetAttachment(req.MailIds)
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"errcode": 0,
|
"errcode": 0,
|
||||||
"errmsg": "success",
|
"errmsg": "",
|
||||||
"attachments": att,
|
"attachments": att,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -141,20 +141,20 @@ type deleteMailsReq struct {
|
|||||||
func (api *MailApi) DeleteMails(c *gin.Context) {
|
func (api *MailApi) DeleteMails(c *gin.Context) {
|
||||||
var req deleteMailsReq
|
var req deleteMailsReq
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
accountObj := GetPlayerMgr().AsyncGetPlayer(req.AccountId)
|
||||||
if accountObj == nil {
|
if accountObj == nil {
|
||||||
err := fmt.Errorf("account is null")
|
err := fmt.Errorf("account is null")
|
||||||
c.JSON(http.StatusBadRequest, errorResponse(400, err))
|
c.JSON(http.StatusBadRequest, errorResponse(http.StatusBadRequest, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
accountObj.DeleteMails(req.MailIds)
|
accountObj.DeleteMails(req.MailIds)
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"errcode": 0,
|
"errcode": 0,
|
||||||
"errmsg": "success",
|
"errmsg": "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ func (m *Mail) IsReadableMail(accountObj common.Player) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nowUnixSec := int32(time.Now().Unix())
|
nowUnixSec := int32(time.Now().Unix())
|
||||||
if m.ExpireTime > nowUnixSec && m.SendTime <= nowUnixSec && accountObj.IsUnreadMail(m.MailId) {
|
if m.ExpireTime > nowUnixSec && m.SendTime <= nowUnixSec && accountObj.IsUnreadMail(m.MailId) && !accountObj.IsDeletedMail(m.MailId) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,30 @@ func (mm *MailMgr) GetMails(player common.Player) []*Mail {
|
|||||||
|
|
||||||
resMailList := make([]*Mail, 0, resMailsSize)
|
resMailList := make([]*Mail, 0, resMailsSize)
|
||||||
for _, gMail := range gameMails {
|
for _, gMail := range gameMails {
|
||||||
if player.IsUnreadMail(gMail.MailId) {
|
newMail := &Mail{
|
||||||
gMail.Flag = 0
|
GameId: gMail.GameId,
|
||||||
} else {
|
MailId: gMail.MailId,
|
||||||
gMail.Flag = 1 << 0
|
From: gMail.From,
|
||||||
|
To: gMail.To,
|
||||||
|
Subject: gMail.Subject,
|
||||||
|
Content: gMail.Content,
|
||||||
|
SendTime: gMail.SendTime,
|
||||||
|
MailType: gMail.MailType,
|
||||||
|
MailSubType: gMail.MailSubType,
|
||||||
|
UserType: gMail.UserType,
|
||||||
|
ExpireTime: gMail.ExpireTime,
|
||||||
|
CreateTime: gMail.CreateTime,
|
||||||
|
Ext: gMail.Ext,
|
||||||
|
ATT: gMail.ATT,
|
||||||
}
|
}
|
||||||
resMailList = append(resMailList, gMail)
|
if player.IsUnreadMail(gMail.MailId) {
|
||||||
|
newMail.Flag = 0
|
||||||
|
} else {
|
||||||
|
newMail.Flag = 1 << 0
|
||||||
|
}
|
||||||
|
resMailList = append(resMailList, newMail)
|
||||||
}
|
}
|
||||||
|
|
||||||
if playerMailSize > 0 {
|
if playerMailSize > 0 {
|
||||||
for _, pMail := range playerMails {
|
for _, pMail := range playerMails {
|
||||||
if player.IsUnreadMail(pMail.MailId) {
|
if player.IsUnreadMail(pMail.MailId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user