english_company.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package models
  2. import (
  3. "eta_gn/eta_report/global"
  4. "time"
  5. )
  6. // EnglishCompany 英文客户
  7. type EnglishCompany struct {
  8. CompanyId int `gorm:"primaryKey;autoIncrement;column:company_id"`
  9. CompanyName string `gorm:"column:company_name" description:"客户名称"`
  10. CountryCode string `gorm:"column:country_code" description:"国家Code"`
  11. Country string `gorm:"column:country" description:"国家"`
  12. SellerId int `gorm:"column:seller_id" description:"销售ID"`
  13. SellerName string `gorm:"column:seller_name" description:"销售姓名"`
  14. ViewTotal int `gorm:"column:view_total" description:"累计点击量/阅读量"`
  15. IsDeleted int `gorm:"column:is_deleted" description:"删除状态:0-正常;1-已删除"`
  16. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  17. ModifyTime time.Time `gorm:"column:modify_time" description:"更新时间"`
  18. }
  19. func (item *EnglishCompany) TableName() string {
  20. return "english_company"
  21. }
  22. func (item *EnglishCompany) Create() (err error) {
  23. err = global.DEFAULT_DmSQL.Create(item).Error
  24. return
  25. }
  26. // EnglishCompanySaveReq 英文客户-保存请求体
  27. type EnglishCompanySaveReq struct {
  28. CompanyId int `description:"客户ID"`
  29. CompanyName string `description:"客户名称"`
  30. CountryCode string `description:"国家代码"`
  31. Country string `description:"国家"`
  32. SellerId int `description:"销售ID"`
  33. }
  34. func (item *EnglishCompany) Update(cols []string) (err error) {
  35. err = global.DEFAULT_DmSQL.Model(item).Select(cols).Updates(item).Error
  36. return
  37. }
  38. // UpdateEnglishCompanyViewTotal 更新英文客户阅读量
  39. func UpdateEnglishCompanyViewTotal(companyId int) (err error) {
  40. sql := `UPDATE english_company SET view_total = view_total+1 WHERE company_id = ? `
  41. err = global.DEFAULT_DmSQL.Exec(sql, companyId).Error
  42. return
  43. }
  44. // UpdateTrialEnglishCompanyViewTotal 更新英文客户阅读量-ETA试用平台
  45. func UpdateTrialEnglishCompanyViewTotal(companyId int) (err error) {
  46. sql := `UPDATE english_company SET view_total = view_total+1 WHERE company_id = ? `
  47. err = global.DEFAULT_DmSQL.Exec(sql, companyId).Error
  48. return
  49. }