1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package models
- import (
- "eta_gn/eta_report/global"
- "time"
- )
- type EnglishReportEmail struct {
- Id int `gorm:"primaryKey;autoIncrement;column:id"`
- CompanyId int `gorm:"column:company_id" description:"客户ID"`
- Name string `gorm:"column:name" description:"联系人名称"`
- Email string `gorm:"column:email" description:"邮箱地址"`
- ViewTotal int `gorm:"column:view_total" description:"累计点击量/阅读量"`
- LastViewTime time.Time `gorm:"column:last_view_time" description:"最后阅读时间"`
- IsDeleted int `gorm:"column:is_deleted" description:"删除状态:0-正常;1-已删除"`
- AdminId int `gorm:"column:admin_id" description:"创建人ID"`
- AdminName string `gorm:"column:admin_name" description:"创建人姓名"`
- CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
- ModifyTime time.Time `gorm:"column:modify_time" description:"更新时间"`
- }
- func (item *EnglishReportEmail) TableName() string {
- return "english_report_email"
- }
- type EnglishReportEmailSaveReq struct {
- Id int `description:"邮箱ID, 大于0为编辑"`
- Name string `description:"客户名称"`
- Email string `description:"邮箱地址"`
- }
- func (item *EnglishReportEmail) Create() (err error) {
- err = global.DEFAULT_DmSQL.Create(item).Error
- return
- }
- func (item *EnglishReportEmail) Update(cols []string) (err error) {
- err = global.DEFAULT_DmSQL.Model(item).Select(cols).Updates(item).Error
- return
- }
- func GetEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
- sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
- err = global.DEFAULT_DmSQL.Raw(sql, id).Scan(&item).Error
- return
- }
- func UpdateEnglishReportEmailViewTotal(emailId int) (err error) {
- sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
- err = global.DEFAULT_DmSQL.Exec(sql, emailId).Error
- return
- }
- func GetTrialEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
- sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
- err = global.DEFAULT_DmSQL.Raw(sql, id).Scan(&item).Error
- return
- }
- func UpdateTrialEnglishReportEmailViewTotal(emailId int) (err error) {
- sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
- err = global.DEFAULT_DmSQL.Exec(sql, emailId).Error
- return
- }
|