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)