english_company.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // EnglishCompany 英文客户
  7. type EnglishCompany struct {
  8. CompanyId int `orm:"column(company_id);pk" description:"英文客户ID"`
  9. CompanyName string `description:"客户名称"`
  10. CountryCode string `description:"国家Code"`
  11. Country string `description:"国家"`
  12. SellerId int `description:"销售ID"`
  13. SellerName string `description:"销售姓名"`
  14. ViewTotal int `description:"累计点击量/阅读量"`
  15. IsDeleted int `description:"删除状态:0-正常;1-已删除"`
  16. CreateTime time.Time `description:"创建时间"`
  17. ModifyTime time.Time `description:"更新时间"`
  18. }
  19. func (item *EnglishCompany) TableName() string {
  20. return "english_company"
  21. }
  22. func (item *EnglishCompany) Create() (err error) {
  23. o := orm.NewOrmUsingDB("rddp")
  24. id, err := o.Insert(item)
  25. if err != nil {
  26. return
  27. }
  28. item.CompanyId = int(id)
  29. return
  30. }
  31. // EnglishCompanySaveReq 英文客户-保存请求体
  32. type EnglishCompanySaveReq struct {
  33. CompanyId int `description:"客户ID"`
  34. CompanyName string `description:"客户名称"`
  35. CountryCode string `description:"国家代码"`
  36. Country string `description:"国家"`
  37. SellerId int `description:"销售ID"`
  38. }
  39. func (item *EnglishCompany) Update(cols []string) (err error) {
  40. o := orm.NewOrmUsingDB("rddp")
  41. _, err = o.Update(item, cols...)
  42. return
  43. }
  44. // GetEnglishCompanyById 主键获取客户
  45. func GetEnglishCompanyById(id int) (item *EnglishCompany, err error) {
  46. o := orm.NewOrmUsingDB("rddp")
  47. sql := `SELECT * FROM english_company WHERE is_deleted = 0 AND company_id = ? LIMIT 1`
  48. err = o.Raw(sql, id).QueryRow(&item)
  49. return
  50. }
  51. // GetEnglishCompanyByName 名称获取客户
  52. func GetEnglishCompanyByName(companyName string) (item *EnglishCompany, err error) {
  53. o := orm.NewOrmUsingDB("rddp")
  54. sql := `SELECT * FROM english_company WHERE is_deleted = 0 AND company_name = ? LIMIT 1`
  55. err = o.Raw(sql, companyName).QueryRow(&item)
  56. return
  57. }
  58. // UpdateEnglishCompanyViewTotal 更新英文客户阅读量
  59. func UpdateEnglishCompanyViewTotal(companyId int) (err error) {
  60. o := orm.NewOrmUsingDB("rddp")
  61. sql := `UPDATE english_company SET view_total = view_total+1 WHERE company_id = ? `
  62. _, err = o.Raw(sql, companyId).Exec()
  63. return
  64. }
  65. // UpdateTrialEnglishCompanyViewTotal 更新英文客户阅读量-ETA试用平台
  66. func UpdateTrialEnglishCompanyViewTotal(companyId int) (err error) {
  67. o := orm.NewOrmUsingDB("rddp_trial")
  68. sql := `UPDATE english_company SET view_total = view_total+1 WHERE company_id = ? `
  69. _, err = o.Raw(sql, companyId).Exec()
  70. return
  71. }