This commit is contained in:
yangduo 2024-08-08 14:00:49 +08:00
parent c9e1c22c44
commit 9c5e60b19c
2 changed files with 15 additions and 10 deletions

View File

@ -25,7 +25,7 @@ func (this *MailApi) ListMail(c *gin.Context) {
inSub := `tag1 IN (` + q5.ToString(jccommon.MAIL_TAG1_CUSTOM)
inSub += ")"
//q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom(inSub).And())
f5.GetDbFilter().Custom("deleted = 0").And()
q5.AppendSlice(&subFilters, f5.GetDbFilter().Custom("deleted = 0").And())
}
mails := []*system.Mail{}
rspObj := struct {
@ -164,7 +164,7 @@ func (this *MailApi) EditMail(c *gin.Context) {
}
var count int64 = 0
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Where("mail_id = ?", reqJson.MailId).Count(&count); count < 1 {
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Table("t_mail").Where("mail_id = ?", reqJson.MailId).Count(&count); count < 1 {
c.JSON(http.StatusOK, gin.H{
"code": 2,
"message": "mailid不存在",
@ -204,7 +204,8 @@ func (this *MailApi) DelMail(c *gin.Context) {
mailid := q5.ToInt64(c.Param("mailid"))
var count int64 = 0
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Table("t_mail").Where("mail_id = ?", mailid).Count(&count); count < 1 {
db := f5.GetApp().GetOrmDb(constant.MAIL_DB).Table("t_mail").Where("mail_id = ?", mailid)
if db.Count(&count); count < 1 {
c.JSON(http.StatusOK, gin.H{
"code": 2,
"message": "mailid不存在",
@ -213,15 +214,19 @@ func (this *MailApi) DelMail(c *gin.Context) {
}
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
mail := new(system.Mail)
mail.MailId = mailid
mail.Deleted = 1
mail.ModifyTime = nowDaySeconds
f5.GetApp().GetOrmDb(constant.MAIL_DB).Save(mail)
delMail := struct {
Deleted int32 `gorm:"column:deleted" json:"-"`
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
}{
1,
nowDaySeconds,
}
db.Save(delMail)
{
e := new(jccommon.MailEvent)
e.EventName = jccommon.EVENT_MAIL_UPDATE
e.Param1 = q5.ToString(mail.MailId)
e.Param1 = q5.ToString(mailid)
e.CreateTime = nowDaySeconds
e.ModifyTime = nowDaySeconds
f5.GetApp().GetOrmDb(constant.MAIL_DB).Create(e)

View File

@ -30,7 +30,7 @@ type Mail struct {
Content string `gorm:"column:content" json:"content"`
Recipients []string `gorm:"column:recipients;serializer:json" json:"recipients"`
Attachments []common.Attachment `gorm:"column:attachments;serializer:json" json:"attachments"`
Deleted int32 `gorm:"column:deleted" json:"deleted"`
Deleted int32 `gorm:"column:deleted" json:"-"`
SendTime int32 `gorm:"column:sendtime" json:"sendtime"`
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"`