This commit is contained in:
aozhiwei 2024-05-11 15:53:00 +08:00
parent 53cbe363b6
commit 37a8773b01
2 changed files with 50 additions and 3 deletions

View File

@ -68,3 +68,50 @@ func (this *MailApi) AddMail(c *gin.Context) {
"message": "",
})
}
func (this *MailApi) EditMail(c *gin.Context) {
reqJson := struct {
MailType int32 `binding:"required" json:"mailtype"`
SendTime int32 `json:"sendtime"`
ExpireTime int32 `json:"expiretime"`
UserRegStartTime int32 `json:"user_reg_start_time"`
UserRegEndTime int32 `json:"user_reg_end_time"`
Subject string `json:"subject"`
Content string `json:"content"`
Attachments []common.Attachment `json:"attachments"`
Recipients []string `json:"recipients"`
}{}
if err := c.ShouldBindJSON(&reqJson); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return
}
if reqJson.MailType <= constant.MAIL_TYPE_BEGIN || reqJson.MailType >= constant.MAIL_TYPE_END {
c.JSON(http.StatusOK, gin.H{
"code": 2,
"message": "mail_type参数错误",
})
return
}
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
mail := new(system.Mail)
mail.MailId = f5.GetApp().NewLockNodeUuid()
mail.MailType = reqJson.MailType
mail.SendTime = reqJson.SendTime
mail.ExpireTime = reqJson.ExpireTime
mail.UserRegStartTime = reqJson.UserRegStartTime
mail.UserRegEndTime = reqJson.UserRegEndTime
mail.Subject = reqJson.Subject
mail.Content = reqJson.Content
mail.Attachments = reqJson.Attachments
mail.Recipients = reqJson.Recipients
mail.CreateTime = nowDaySeconds
mail.ModifyTime = nowDaySeconds
f5.GetApp().GetOrmDb(constant.MAIL_DB).Save(mail)
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
}

View File

@ -23,8 +23,8 @@ Attachments:
*/
type Mail struct {
MailId int64 `gorm:"primaryKey;column:mail_id" json:"mail_id"`
MailType int32 `gorm:"column:mail_type" json:"mail_type"`
MailId int64 `gorm:"primaryKey;column:mail_id;<-:create" json:"mail_id"`
MailType int32 `gorm:"column:mail_type;<-:create" json:"mail_type"`
Subject string `gorm:"column:subject" json:"subject"`
Content string `gorm:"column:content" json:"content"`
Recipients []string `gorm:"column:recipients;serializer:json" json:"recipients"`
@ -34,7 +34,7 @@ type Mail struct {
UserRegStartTime int32 `gorm:"column:user_reg_start_time" json:"user_reg_start_time"`
UserRegEndTime int32 `gorm:"column:user_reg_end_time" json:"user_reg_end_time"`
ExpireTime int32 `gorm:"column:expiretime" json:"expiretime"`
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
CreateTime int32 `gorm:"column:createtime;<-:create" json:"createtime"`
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
}