english_report_email.go 3.0 KB

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