12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package chart_collect
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- // 图表收藏每日汇总统计表
- type ChartCollectStat struct {
- ChartCollectStatId int `orm:"column(chart_collect_stat_id);pk"`
- ChartInfoId int `description:"图表ID"`
- CollectDate string `description:"收藏日期"`
- CollectNum int `description:"收藏的图表数量"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- // 根据图表ID和日期获取图表收藏统计信息
- func GetChartCollectStatByChartInfoIdAndCollectDate(chartInfoId int, collectDate string) (stat *ChartCollectStat, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM chart_collect_stat WHERE chart_info_id = ? AND collect_date = ?"
- err = o.Raw(sql, chartInfoId, collectDate).QueryRow(&stat)
- return
- }
- // 用户收藏图表每日汇总表
- 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
- }
- // 获取该用户数量
- func (u *UserCollectChartStat) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrm()
- tmpSql := `SELECT s.* FROM user_collect_chart_stat AS s LEFT JOIN user AS u on s.user_id=u.user_id WHERE 1=1 `
- if condition != "" {
- tmpSql += condition
- }
- sql := `SELECT COUNT(1) AS count FROM (` + tmpSql + `) AS c `
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- // 获取该用户列表
- func (u *UserCollectChartStat) GetPageListByCondition(condition string, pars []interface{}, order string, startSize, pageSize int) (items []*UserCollectChartStatItem, err error) {
- o := orm.NewOrm()
- tmpSql := `SELECT s.*, u.last_collect_chart_time, u.business_code, u.real_name, u.eta_business_id FROM user_collect_chart_stat AS s LEFT JOIN user AS u on s.user_id=u.user_id WHERE 1=1 `
- if condition != "" {
- tmpSql += condition
- }
- if order != "" {
- tmpSql += ` ORDER BY ` + order + " s.chart_collect_stat_id DESC"
- } else {
- tmpSql += ` ORDER BY s.chart_collect_stat_id DESC`
- }
- tmpSql += ` Limit ?,?`
- _, err = o.Raw(tmpSql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type UserStatListResp struct {
- Paging *paging.PagingItem
- List []*UserCollectChartStatItem
- }
- type UserCollectChartStatItem struct {
- UserId int `description:"用户ID"`
- BusinessCode string `description:"客户编码"`
- RealName string `description:"用户姓名"`
- EtaBusinessId int
- BusinessName string
- CollectNum int `description:"收藏的图表数量"`
- CollectDate string
- LastCollectChartTime string
- }
|