package english_report_email import ( "hongze/hongze_yb_en_api/global" "time" ) // 英文研报-邮箱PV type EmailPv struct { Id uint `gorm:"primaryKey;column:id" json:"id"` ReportId uint `gorm:"column:report_id" json:"report_id"` //报告ID EmailId uint `gorm:"column:email_id" json:"email_id"` //邮箱ID ReportType uint `gorm:"column:report_type" json:"report_type"` //分类类型:0英文报告,1英文线上路演 CreateTime time.Time `gorm:"column:create_time" json:"create_time"` //访问时间 } // TableName get sql table name.获取数据库表名 func (e *EmailPv) TableName() string { return "english_report_email_pv" } // Add 新增 func (e *EmailPv) Add() (err error) { err = global.DEFAULT_MYSQL.Create(e).Error return } func GetDistinctEmailPvCount(reportId int) (count int, err error) { sql := `SELECT COUNT(DISTINCT email_id) FROM english_report_email_pv WHERE report_id = ? AND report_type = 0` err = global.DEFAULT_MYSQL.Raw(sql, reportId).Scan(&count).Error return }