From 158ea726cfadea3e07e08cf1a9449543da1235a8 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 7 Dec 2022 11:40:41 +0800 Subject: [PATCH] =?UTF-8?q?web=20=E9=82=AE=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/api_creatmail.go | 46 ++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/modules/web/api_creatmail.go b/modules/web/api_creatmail.go index fbaca003e..04fe61f69 100644 --- a/modules/web/api_creatmail.go +++ b/modules/web/api_creatmail.go @@ -5,11 +5,19 @@ import ( "go_dreamfactory/lego/sys/gin/engine" "go_dreamfactory/pb" "net/http" + "time" + + "go.mongodb.org/mongo-driver/bson/primitive" ) type CrateMailReq struct { - pb.DBMailData - Sign string `json:"sign"` + Uid string // uid + Title string // 邮件标题 + Contex string // 邮件内容 支持自定义 + Items []*pb.UserAssets // 附件 + Cid string // 多语言表id + Param []string // 自定义参数 + Sign string `json:"sign"` } //创建邮件 @@ -23,15 +31,13 @@ func (this *Api_Comp) CreateMail(c *engine.Context) { data interface{} ) defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data}) - if sign := gin.ParamSign(this.options.Key, map[string]interface{}{ - "Uid": req.Uid, - "Title": req.Title, - "Contex": req.Contex, - "CreateTime": req.CreateTime, - "DueTime": req.DueTime, - "Check": req.Check, - "Reward": req.Reward, - "Items": req.Items, + if sign := gin.ParamSign(this.options.Key, map[string]interface{}{ + "Uid": req.Uid, + "Title": req.Title, + "Contex": req.Contex, + "Items": req.Items, + "Cid": req.Cid, + "Param": req.Param, }); sign != req.Sign { this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign) code = pb.ErrorCode_SignError @@ -43,7 +49,23 @@ func (this *Api_Comp) CreateMail(c *engine.Context) { msg = pb.GetErrorCodeMsg(code) return } - if err = this.module.modelMail.CreateGMMail(&req.DBMailData); err != nil { + mail := &pb.DBMailData{ + ObjId: primitive.NewObjectID().Hex(), + Uid: req.Uid, + Title: req.Title, + Contex: req.Contex, + CreateTime: uint64(time.Now().Unix()), + DueTime: uint64(time.Now().Unix() + 30*24*3600), + Check: false, + Reward: false, + Items: req.Items, + Cid: req.Cid, + Param: req.Param, + } + if len(req.Items) > 0 { + mail.Reward = true + } + if err = this.module.modelMail.CreateGMMail(mail); err != nil { this.module.Errorf("LoginByCaptchaReq CreateMail err:%v", err) code = pb.ErrorCode_DBError msg = pb.GetErrorCodeMsg(code)