|
@@ -10,6 +10,9 @@ import (
|
|
|
type ChartCollectStat struct {
|
|
|
ChartCollectStatId int `orm:"column(chart_collect_stat_id);pk"`
|
|
|
ChartInfoId int `description:"图表ID"`
|
|
|
+ ChartSource int `description:"1:ETA图库;2:商品价格曲线;3:相关性图"`
|
|
|
+ ChartName string `description:"图表名称"`
|
|
|
+ LastCollectTime time.Time `description:"最后被收藏的时间"`
|
|
|
CollectDate string `description:"收藏日期"`
|
|
|
CollectNum int `description:"收藏的图表数量"`
|
|
|
CreateTime time.Time `description:"创建时间"`
|
|
@@ -26,23 +29,16 @@ func GetChartCollectStatByChartInfoIdAndCollectDate(chartInfoId int, collectDate
|
|
|
|
|
|
// 用户收藏图表每日汇总表
|
|
|
type UserCollectChartStat struct {
|
|
|
- UserChartStatId int `orm:"column(user_chart_stat_id);pk"`
|
|
|
- UserId int `description:"用户ID"`
|
|
|
- BusinessCode string `description:"客户编码"`
|
|
|
- RealName string `description:"用户姓名"`
|
|
|
- CollectDate string `description:"收藏日期"`
|
|
|
- CollectNum int `description:"收藏的图表数量"`
|
|
|
- ChartSource int `description:"1:ETA图库;2:商品价格曲线;3:相关性图"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- ModifyTime time.Time `description:"修改时间"`
|
|
|
-}
|
|
|
-
|
|
|
-// 根据用户ID和日期获取图表收藏统计信息
|
|
|
-func GetUserCollectChartStatByUserIdAndCollectDate(userId int, collectDate string) (stat *UserCollectChartStat, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := "SELECT * FROM chart_collect_stat WHERE user_id = ? AND collect_date = ?"
|
|
|
- err = o.Raw(sql, userId, collectDate).QueryRow(&stat)
|
|
|
- return
|
|
|
+ UserChartStatId int `orm:"column(user_chart_stat_id);pk"`
|
|
|
+ UserId int `description:"用户ID"`
|
|
|
+ BusinessCode string `description:"客户编码"`
|
|
|
+ EtaBusinessId int
|
|
|
+ RealName string `description:"用户姓名"`
|
|
|
+ CollectDate string `description:"收藏日期"`
|
|
|
+ CollectNum int `description:"收藏的图表数量"`
|
|
|
+ LastCollectChartTime time.Time `description:"最近收藏图表时间"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+ ModifyTime time.Time `description:"修改时间"`
|
|
|
}
|
|
|
|
|
|
// 获取该用户数量
|
|
@@ -65,7 +61,7 @@ func (u *UserCollectChartStat) GetPageListByCondition(condition string, pars []i
|
|
|
tmpSql += condition
|
|
|
}
|
|
|
if order != "" {
|
|
|
- tmpSql += ` ORDER BY ` + order + " user_chart_stat_id DESC"
|
|
|
+ tmpSql += ` ORDER BY ` + order + ", user_chart_stat_id DESC"
|
|
|
} else {
|
|
|
tmpSql += ` ORDER BY user_chart_stat_id DESC`
|
|
|
}
|
|
@@ -89,3 +85,21 @@ type UserCollectChartStatItem struct {
|
|
|
CollectDate string
|
|
|
LastCollectChartTime string
|
|
|
}
|
|
|
+
|
|
|
+type ChartCollectChartStatItem struct {
|
|
|
+ ChartInfoId int `description:"图表ID"`
|
|
|
+ ChartName string `description:"图表名称"`
|
|
|
+ LastCollectTime string `description:"最后被收藏的时间"`
|
|
|
+ CollectNum int `description:"收藏的图表数量"`
|
|
|
+}
|
|
|
+type ChartStatListResp struct {
|
|
|
+ List []*ChartCollectChartStatItem
|
|
|
+}
|
|
|
+
|
|
|
+// 获取该用户列表
|
|
|
+func (u *ChartCollectStat) GetChartInfoStatusNum() (items []*ChartCollectChartStatItem, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ tmpSql := `SELECT sum(collect_num) as collect_num, max(last_collect_time) as last_collect_time, chart_info_id, chart_name FROM chart_collect_stat group by chart_info_id ORDER BY sum(collect_num) DESC limit 0, 20`
|
|
|
+ _, err = o.Raw(tmpSql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|