log.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package chart_collect
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type ChartCollectLog struct {
  8. Id int `orm:"column(id);pk"`
  9. UserId int `description:"用户ID"`
  10. BusinessCode string `description:"客户编码"`
  11. RealName string `description:"用户姓名"`
  12. ChartInfoId int `description:"图表ID"`
  13. CollectState int `description:"-1 取消收藏,1收藏"`
  14. CollectTime time.Time `description:"收藏时间"`
  15. CollectClassifyId int `description:"图表分类ID(注意:此字段的注释可能与实际意图不符,原文为'图表ID')"`
  16. ChartSource int `description:"1:ETA图库;2:商品价格曲线;3:相关性图"`
  17. CreateTime time.Time `description:"创建时间"`
  18. }
  19. // 获取该用户数量
  20. func (u *ChartCollectLog) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
  21. o := orm.NewOrm()
  22. tmpSql := `SELECT * FROM user_collect_chart_stat WHERE collect_state=1 `
  23. if condition != "" {
  24. tmpSql += condition
  25. }
  26. tmpSql += ` group by chart_info_id `
  27. sql := `SELECT COUNT(1) AS count FROM (` + tmpSql + `) AS c `
  28. err = o.Raw(sql, pars).QueryRow(&count)
  29. return
  30. }
  31. // 获取该用户列表
  32. func (u *UserCollectChartStat) GetPageListByCondition(condition string, pars []interface{}, order string, startSize, pageSize int) (items []*ChartCollectLog, err error) {
  33. o := orm.NewOrm()
  34. tmpSql := `SELECT * FROM user_collect_chart_stat WHERE collect_state=1 `
  35. if condition != "" {
  36. tmpSql += condition
  37. }
  38. tmpSql += ` group by chart_info_id `
  39. if order != "" {
  40. tmpSql += ` ORDER BY ` + order + ", user_chart_stat_id DESC"
  41. } else {
  42. tmpSql += ` ORDER BY user_chart_stat_id DESC`
  43. }
  44. tmpSql += ` Limit ?,?`
  45. _, err = o.Raw(tmpSql, pars, startSize, pageSize).QueryRows(&items)
  46. return
  47. }
  48. type UserChartDetailListResp struct {
  49. Paging *paging.PagingItem
  50. List []*UserChartDetailListItem
  51. }
  52. type UserChartDetailListItem struct {
  53. ChartInfoId int `description:"图表ID"`
  54. CollectTime string `description:"收藏时间"`
  55. }