From 90da74ed6c738127f9fea4542c1cbd886a15e2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B7=E5=8B=87?= Date: Wed, 1 Nov 2023 14:10:50 +0800 Subject: [PATCH] save --- server/mailserver/api/mailmgr.go | 56 ++++++++++++++------------------ server/mailserver/mail/mail.go | 4 +-- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/server/mailserver/api/mailmgr.go b/server/mailserver/api/mailmgr.go index 331edc17..24cf7091 100644 --- a/server/mailserver/api/mailmgr.go +++ b/server/mailserver/api/mailmgr.go @@ -63,7 +63,7 @@ func (api *MailMgrApi) SendMail(c *gin.Context) { return } - sql := fmt.Sprintf("INSERT INTO mailbox SET gameid=%d, mailid=%d, mailtype=%d, mailsubtype=%d, _to=%s, subject=%s, content=%s, deleted=0, attachments=%s, sendtime=%d, expiretime=%d, createtime=%d, modifytime=%d, ext=%s, usertype=%d", + sql := fmt.Sprintf("INSERT INTO mailbox SET gameid=%d, mailid=%d, mailtype=%d, mailsubtype=%d, _to='%s', subject='%s', content='%s', deleted=0, attachments='%s', sendtime=%d, expiretime=%d, createtime=%d, modifytime=%d, ext='%s', usertype=%d", req.GameId, mailId, req.MailType, @@ -86,24 +86,22 @@ func (api *MailMgrApi) SendMail(c *gin.Context) { f5.GetSysLog().Info("SendMail err:%v \n", err) return } - if rows.Next() { - newMail := mail.NewMail() - newMail.GameId = req.GameId - newMail.MailId = mailId - newMail.From = req.From - newMail.To = req.To - newMail.Subject = req.Subject - newMail.Content = req.Content - newMail.MailType = req.MailType - newMail.MailSubType = req.MailSubType - newMail.UserType = req.UserType - newMail.SendTime = req.SendTime - newMail.ExpireTime = req.ExpireTime - newMail.CreateTime = nowUnixSec - newMail.Ext = req.EXT - newMail.ParseAttachments(req.Attachments) - GetMailMgr().AddMail(newMail) - } + newMail := mail.NewMail() + newMail.GameId = req.GameId + newMail.MailId = mailId + newMail.From = req.From + newMail.To = req.To + newMail.Subject = req.Subject + newMail.Content = req.Content + newMail.MailType = req.MailType + newMail.MailSubType = req.MailSubType + newMail.UserType = req.UserType + newMail.SendTime = req.SendTime + newMail.ExpireTime = req.ExpireTime + newMail.CreateTime = nowUnixSec + newMail.Ext = req.EXT + newMail.ParseAttachments(req.Attachments) + GetMailMgr().AddMail(newMail) }, ) @@ -151,9 +149,7 @@ func (api *MailMgrApi) DeleteMail(c *gin.Context) { f5.GetSysLog().Info("DeleteMail err:%v \n", err) return } - if rows.Next() { - GetMailMgr().InternalGMDeleteMail(req.MailId) - } + GetMailMgr().InternalGMDeleteMail(req.MailId) }, ) @@ -206,7 +202,7 @@ func (api *MailMgrApi) UpdateMail(c *gin.Context) { return } - sql := fmt.Sprintf("UPDATE mailbox SET content=%s,subject=%s,sendtime=%d,expiretime=%d,ext=%s, attachments=%s, WHERE mailid=%d", req.Content, req.Subject, req.SendTime, req.ExpireTime, req.EXT, req.Attachments, req.MailId) + sql := fmt.Sprintf("UPDATE mailbox SET content='%s',subject='%s',sendtime=%d,expiretime=%d,ext='%s', attachments='%s' WHERE mailid=%d", req.Content, req.Subject, req.SendTime, req.ExpireTime, req.EXT, req.Attachments, req.MailId) f5.GetGoStyleDb().SyncSelectCustomQuery( constant.MAIL_DB, sql, @@ -215,14 +211,12 @@ func (api *MailMgrApi) UpdateMail(c *gin.Context) { f5.GetSysLog().Info("UpdateMail err:%v \n", err) return } - if rows.Next() { - m.Content = req.Content - m.Subject = req.Subject - m.SendTime = req.SendTime - m.ExpireTime = req.ExpireTime - m.Ext = req.EXT - m.ParseAttachments(req.Attachments) - } + m.Content = req.Content + m.Subject = req.Subject + m.SendTime = req.SendTime + m.ExpireTime = req.ExpireTime + m.Ext = req.EXT + m.ParseAttachments(req.Attachments) }, ) diff --git a/server/mailserver/mail/mail.go b/server/mailserver/mail/mail.go index 29982830..83f98421 100644 --- a/server/mailserver/mail/mail.go +++ b/server/mailserver/mail/mail.go @@ -16,7 +16,7 @@ type Attachment struct { // GMMail mail mgr type GMMail struct { GameId int `json:"gameid"` - MailId int64 `json:"mailid"` + MailId int64 `json:"mailid,string"` From string `json:"from"` To string `json:"to"` Subject string `json:"subject"` @@ -31,7 +31,7 @@ type GMMail struct { type Mail struct { GameId int `json:"-"` - MailId int64 `json:"mailid"` + MailId int64 `json:"mailid,string"` From string `json:"from"` To string `json:"to"` Subject string `json:"subject"`