english_report_email.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package models
  2. import (
  3. "eta_gn/eta_report/global"
  4. "time"
  5. )
  6. // EnglishReportEmail 英文研报-邮箱/客户联系人
  7. type EnglishReportEmail struct {
  8. Id int `gorm:"primaryKey;autoIncrement;column:id"`
  9. CompanyId int `gorm:"column:company_id" description:"客户ID"`
  10. Name string `gorm:"column:name" description:"联系人名称"`
  11. Email string `gorm:"column:email" description:"邮箱地址"`
  12. ViewTotal int `gorm:"column:view_total" description:"累计点击量/阅读量"`
  13. LastViewTime time.Time `gorm:"column:last_view_time" description:"最后阅读时间"`
  14. IsDeleted int `gorm:"column:is_deleted" description:"删除状态:0-正常;1-已删除"`
  15. AdminId int `gorm:"column:admin_id" description:"创建人ID"`
  16. AdminName string `gorm:"column:admin_name" description:"创建人姓名"`
  17. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  18. ModifyTime time.Time `gorm:"column:modify_time" description:"更新时间"`
  19. }
  20. func (item *EnglishReportEmail) TableName() string {
  21. return "english_report_email"
  22. }
  23. // EnglishReportEmailSaveReq 保存邮箱请求体
  24. type EnglishReportEmailSaveReq struct {
  25. Id int `description:"邮箱ID, 大于0为编辑"`
  26. Name string `description:"客户名称"`
  27. Email string `description:"邮箱地址"`
  28. }
  29. func (item *EnglishReportEmail) Create() (err error) {
  30. // 使用 GORM 插入记录
  31. err = global.DEFAULT_DmSQL.Create(item).Error
  32. return
  33. }
  34. func (item *EnglishReportEmail) Update(cols []string) (err error) {
  35. err = global.DEFAULT_DmSQL.Model(item).Select(cols).Updates(item).Error
  36. return
  37. }
  38. // GetEnglishReportEmailById 主键获取邮箱
  39. func GetEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
  40. sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
  41. err = global.DEFAULT_DmSQL.Raw(sql, id).Scan(&item).Error
  42. return
  43. }
  44. // UpdateEnglishReportEmailViewTotal 更新英文联系人阅读量
  45. func UpdateEnglishReportEmailViewTotal(emailId int) (err error) {
  46. sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
  47. err = global.DEFAULT_DmSQL.Exec(sql, emailId).Error
  48. return
  49. }
  50. // GetTrialEnglishReportEmailById 主键获取邮箱-ETA试用平台
  51. func GetTrialEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
  52. sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
  53. err = global.DEFAULT_DmSQL.Raw(sql, id).Scan(&item).Error
  54. return
  55. }
  56. // UpdateTrialEnglishReportEmailViewTotal 更新英文联系人阅读量-ETA试用平台
  57. func UpdateTrialEnglishReportEmailViewTotal(emailId int) (err error) {
  58. sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
  59. err = global.DEFAULT_DmSQL.Exec(sql, emailId).Error
  60. return
  61. }