123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package models
- import (
- "eta_gn/eta_report/global"
- "time"
- )
- // EnglishReportEmail 英文研报-邮箱/客户联系人
- 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"
- }
- // EnglishReportEmailSaveReq 保存邮箱请求体
- type EnglishReportEmailSaveReq struct {
- Id int `description:"邮箱ID, 大于0为编辑"`
- Name string `description:"客户名称"`
- Email string `description:"邮箱地址"`
- }
- func (item *EnglishReportEmail) Create() (err error) {
- // 使用 GORM 插入记录
- 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
- }
- // GetEnglishReportEmailById 主键获取邮箱
- 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
- }
- // UpdateEnglishReportEmailViewTotal 更新英文联系人阅读量
- 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
- }
- // GetTrialEnglishReportEmailById 主键获取邮箱-ETA试用平台
- 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
- }
- // UpdateTrialEnglishReportEmailViewTotal 更新英文联系人阅读量-ETA试用平台
- 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
- }
|