user_interaction_num.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxUserInteractionNum struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int `description:"用户ID"`
  9. ArticleHistoryNum int `description:"文章浏览数量"`
  10. ArticleCountNum int `description:"文章收藏数量"`
  11. ChartCountNum int `description:"图表收藏"`
  12. IndustryFllowNum int `description:"产业关注数量"`
  13. DepartmentFollowNum int `description:"作者关注数量"`
  14. KeyWordNum int `description:"关键词搜索次数"`
  15. ActivityOnLineNum int `description:"线上活动报名次数"`
  16. ActivityOfficeNum int `description:"线下活动报名次数"`
  17. ActivityNum int `description:"活动报名次数"`
  18. TripNum int `description:"专项产业调研数量"`
  19. RoadshowVideoNum int `description:"产业视频播放量"`
  20. ActivityVideoNum int `description:"活动视频播放量"`
  21. ActivityVoiceNum int `description:"活动音频播放量"`
  22. RoadshowNum int `description:"路演播放总数量"`
  23. TagNum int `description:"标签点击次数"`
  24. CreateTime time.Time `description:"创建时间"`
  25. ModifyTime time.Time `description:"更新时间"`
  26. }
  27. // 添加
  28. func AddCygxUserInteractionNum(item *CygxUserInteractionNum) (lastId int64, err error) {
  29. o := orm.NewOrm()
  30. lastId, err = o.Insert(item)
  31. return
  32. }
  33. // 修改
  34. func UpdateCygxUserInteractionNum(item *CygxUserInteractionNum) (err error) {
  35. updateParams := make(map[string]interface{})
  36. updateParams["UserId"] = item.UserId
  37. updateParams["ArticleHistoryNum"] = item.ArticleHistoryNum
  38. updateParams["ArticleCountNum"] = item.ArticleCountNum
  39. updateParams["ChartCountNum"] = item.ChartCountNum
  40. updateParams["IndustryFllowNum"] = item.IndustryFllowNum
  41. updateParams["DepartmentFollowNum"] = item.DepartmentFollowNum
  42. updateParams["KeyWordNum"] = item.KeyWordNum
  43. updateParams["ActivityOnLineNum"] = item.ActivityOnLineNum
  44. updateParams["ActivityOfficeNum"] = item.ActivityOfficeNum
  45. updateParams["ActivityNum"] = item.ActivityNum
  46. updateParams["TripNum"] = item.TripNum
  47. updateParams["RoadshowVideoNum"] = item.RoadshowVideoNum
  48. updateParams["ActivityVideoNum"] = item.ActivityVideoNum
  49. updateParams["ActivityVoiceNum"] = item.ActivityVoiceNum
  50. updateParams["RoadshowNum"] = item.RoadshowNum
  51. updateParams["TagNum"] = item.TagNum
  52. updateParams["CreateTime"] = time.Now()
  53. updateParams["ModifyTime"] = time.Now()
  54. whereParam := map[string]interface{}{"user_id": item.UserId}
  55. err = UpdateByExpr(CygxUserInteractionNum{}, whereParam, updateParams)
  56. return
  57. }
  58. // 获取列表
  59. func GetCygxUserInteractionNumList() (items []*CygxUserInteractionNum, err error) {
  60. o := orm.NewOrm()
  61. sql := `SELECT * FROM cygx_user_interaction_num `
  62. _, err = o.Raw(sql).QueryRows(&items)
  63. return
  64. }
  65. // 批量添加用户互动信息
  66. func AddCygxUserInteractionNumList(items []*CygxUserInteractionNum) (lastId int64, err error) {
  67. o := orm.NewOrm()
  68. _, err = o.InsertMulti(1, items)
  69. return
  70. }