product_interior_history.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxProductInteriorHistory struct {
  7. Id int `orm:"column(id);pk"`
  8. ProductInteriorId int
  9. UserId int
  10. CreateTime time.Time
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. ModifyTime time.Time `description:"修改时间"`
  16. RealName string `description:"用户实际名称"`
  17. SellerName string `description:"所属销售"`
  18. }
  19. // 添加历史信息
  20. func AddCygxProductInteriorHistory(item *CygxProductInteriorHistory) (lastId int64, err error) {
  21. o := orm.NewOrm()
  22. item.ModifyTime = time.Now()
  23. lastId, err = o.Insert(item)
  24. return
  25. }
  26. type ListProductInteriorPvUvResp struct {
  27. ProductInteriorId int `description:"文章ID"`
  28. Pv int `description:"pv"`
  29. Uv int `description:"pv"`
  30. }
  31. // 列表
  32. func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*ListProductInteriorPvUvResp, err error) {
  33. o := orm.NewOrm()
  34. sql := `SELECT
  35. COUNT( 1 ) AS pv,
  36. product_interior_id
  37. FROM
  38. cygx_product_interior_history WHERE 1 = 1 `
  39. if condition != "" {
  40. sql += condition
  41. }
  42. sql += ` GROUP BY product_interior_id `
  43. _, err = o.Raw(sql, pars).QueryRows(&items)
  44. return
  45. }
  46. type ListProductInteriorPvResp struct {
  47. ProductInteriorId int `description:"文章ID"`
  48. Pv int `description:"pv"`
  49. }
  50. // 列表
  51. func GetCygxProductInteriorHistoryListPv(condition string, pars []interface{}) (items []*ListProductInteriorPvResp, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT product_interior_id ,COUNT(*) as pv FROM cygx_product_interior_history WHERE 1= 1 `
  54. if condition != "" {
  55. sql += condition
  56. }
  57. sql += " GROUP BY product_interior_id "
  58. _, err = o.Raw(sql, pars).QueryRows(&items)
  59. return
  60. }