package models import ( "github.com/beego/beego/v2/client/orm" "time" ) // EnglishReportEmail 英文研报-邮箱/客户联系人 type EnglishReportEmail struct { Id int `orm:"column(id);pk" description:"邮箱ID"` CompanyId int `description:"客户ID"` Name string `description:"联系人名称"` Email string `description:"邮箱地址"` ViewTotal int `description:"累计点击量/阅读量"` LastViewTime time.Time `description:"最后阅读时间"` IsDeleted int `description:"删除状态:0-正常;1-已删除"` AdminId int `description:"创建人ID"` AdminName string `description:"创建人姓名"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"更新时间"` } func (item *EnglishReportEmail) TableName() string { return "english_report_email" } // EnglishReportEmailSaveReq 保存邮箱请求体 type EnglishReportEmailSaveReq struct { Id int `description:"邮箱ID, 大于0为编辑"` Name string `description:"客户名称"` Email string `description:"邮箱地址"` } func (item *EnglishReportEmail) Create() (err error) { o := orm.NewOrm() id, err := o.Insert(item) if err != nil { return } item.Id = int(id) return } func (item *EnglishReportEmail) Update(cols []string) (err error) { o := orm.NewOrm() _, err = o.Update(item, cols...) return } // GetEnglishReportEmailById 主键获取邮箱 func GetEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) { o := orm.NewOrm() sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1` err = o.Raw(sql, id).QueryRow(&item) return } // UpdateEnglishReportEmailViewTotal 更新英文联系人阅读量 func UpdateEnglishReportEmailViewTotal(emailId int) (err error) { o := orm.NewOrm() sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? ` _, err = o.Raw(sql, emailId).Exec() return } // GetTrialEnglishReportEmailById 主键获取邮箱-ETA试用平台 func GetTrialEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) { o := orm.NewOrm() sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1` err = o.Raw(sql, id).QueryRow(&item) return } // UpdateTrialEnglishReportEmailViewTotal 更新英文联系人阅读量-ETA试用平台 func UpdateTrialEnglishReportEmailViewTotal(emailId int) (err error) { o := orm.NewOrm() sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? ` _, err = o.Raw(sql, emailId).Exec() return }