english_report_email.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // EnglishReportEmail 英文研报-邮箱/客户联系人
  7. type EnglishReportEmail struct {
  8. Id int `orm:"column(id);pk" description:"邮箱ID"`
  9. CompanyId int `description:"客户ID"`
  10. Name string `description:"联系人名称"`
  11. Email string `description:"邮箱地址"`
  12. ViewTotal int `description:"累计点击量/阅读量"`
  13. LastViewTime time.Time `description:"最后阅读时间"`
  14. IsDeleted int `description:"删除状态:0-正常;1-已删除"`
  15. AdminId int `description:"创建人ID"`
  16. AdminName string `description:"创建人姓名"`
  17. CreateTime time.Time `description:"创建时间"`
  18. ModifyTime time.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. o := orm.NewOrm()
  31. id, err := o.Insert(item)
  32. if err != nil {
  33. return
  34. }
  35. item.Id = int(id)
  36. return
  37. }
  38. func (item *EnglishReportEmail) Update(cols []string) (err error) {
  39. o := orm.NewOrm()
  40. _, err = o.Update(item, cols...)
  41. return
  42. }
  43. // GetEnglishReportEmailById 主键获取邮箱
  44. func GetEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
  45. o := orm.NewOrm()
  46. sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
  47. err = o.Raw(sql, id).QueryRow(&item)
  48. return
  49. }
  50. // UpdateEnglishReportEmailViewTotal 更新英文联系人阅读量
  51. func UpdateEnglishReportEmailViewTotal(emailId int) (err error) {
  52. o := orm.NewOrm()
  53. sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
  54. _, err = o.Raw(sql, emailId).Exec()
  55. return
  56. }
  57. // GetTrialEnglishReportEmailById 主键获取邮箱-ETA试用平台
  58. func GetTrialEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
  59. o := orm.NewOrm()
  60. sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
  61. err = o.Raw(sql, id).QueryRow(&item)
  62. return
  63. }
  64. // UpdateTrialEnglishReportEmailViewTotal 更新英文联系人阅读量-ETA试用平台
  65. func UpdateTrialEnglishReportEmailViewTotal(emailId int) (err error) {
  66. o := orm.NewOrm()
  67. sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
  68. _, err = o.Raw(sql, emailId).Exec()
  69. return
  70. }