From 867c237e87bea7898f706082b8ace1d8a5859271 Mon Sep 17 00:00:00 2001 From: yangduo Date: Thu, 15 Aug 2024 14:36:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=82=AE=E4=BB=B6=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/adminserver/api/v1/system/mail.go | 33 +++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/server/adminserver/api/v1/system/mail.go b/server/adminserver/api/v1/system/mail.go index 4a39e9a3..4624e129 100644 --- a/server/adminserver/api/v1/system/mail.go +++ b/server/adminserver/api/v1/system/mail.go @@ -10,6 +10,7 @@ import ( "main/mt" "net/http" "q5" + "strings" "fmt" @@ -138,7 +139,7 @@ func (this *MailApi) AddMail(c *gin.Context) { return } - if !this.CheckRecipients(reqJson.Recipients, c) { + if reqJson.MailType == jccommon.MAIL_TYPE_GROUP && !this.CheckRecipients(&reqJson.Recipients, c) { return } @@ -226,7 +227,7 @@ func (this *MailApi) EditMail(c *gin.Context) { return } - if !this.CheckRecipients(reqJson.Recipients, c) { + if reqJson.MailType == jccommon.MAIL_TYPE_GROUP && !this.CheckRecipients(&reqJson.Recipients, c) { return } @@ -343,13 +344,21 @@ func (this *MailApi) CheckAttachment(list []common.Attachment, c *gin.Context) b return false } + if item.ItemNum < 1 { + c.JSON(http.StatusOK, gin.H{ + "code": 2, + "message": "item 数量错误 :" + q5.SafeToString(item.ItemId), + }) + return false + } + passeditem[item.ItemId] = item.ItemNum } return true } -func (this *MailApi) CheckRecipients(list []string, c *gin.Context) bool { +func (this *MailApi) CheckRecipients(list *[]string, c *gin.Context) bool { if data, err := json.Marshal(list); err != nil || len(data) > 0xFFFF { c.JSON(http.StatusOK, gin.H{ "code": 2, @@ -358,5 +367,23 @@ func (this *MailApi) CheckRecipients(list []string, c *gin.Context) bool { return false } + newlist := []string{} + for idx := range *list { + (*list)[idx] = strings.ReplaceAll((*list)[idx], " ", "") + if (*list)[idx] != "" { + newlist = append(newlist, (*list)[idx]) + } + } + + if len(newlist) == 0 { + c.JSON(http.StatusOK, gin.H{ + "code": 2, + "message": "收件人错误", + }) + return false + } + + list = &newlist + return true }