12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package chart_collect
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type ChartCollectLog struct {
- Id int `orm:"column(id);pk"`
- UserId int `description:"用户ID"`
- BusinessCode string `description:"客户编码"`
- RealName string `description:"用户姓名"`
- ChartInfoId int `description:"图表ID"`
- CollectState int `description:"-1 取消收藏,1收藏"`
- CollectTime time.Time `description:"收藏时间"`
- CollectClassifyId int `description:"图表分类ID(注意:此字段的注释可能与实际意图不符,原文为'图表ID')"`
- ChartSource int `description:"1:ETA图库;2:商品价格曲线;3:相关性图"`
- CreateTime time.Time `description:"创建时间"`
- }
- // 获取该用户数量
- func (u *ChartCollectLog) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrm()
- tmpSql := `SELECT * FROM user_collect_chart_stat WHERE collect_state=1 `
- if condition != "" {
- tmpSql += condition
- }
- tmpSql += ` group by chart_info_id `
- 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 []*ChartCollectLog, err error) {
- o := orm.NewOrm()
- tmpSql := `SELECT * FROM user_collect_chart_stat WHERE collect_state=1 `
- if condition != "" {
- tmpSql += condition
- }
- tmpSql += ` group by chart_info_id `
- if order != "" {
- tmpSql += ` ORDER BY ` + order + ", user_chart_stat_id DESC"
- } else {
- tmpSql += ` ORDER BY user_chart_stat_id DESC`
- }
- tmpSql += ` Limit ?,?`
- _, err = o.Raw(tmpSql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type UserChartDetailListResp struct {
- Paging *paging.PagingItem
- List []*UserChartDetailListItem
- }
- type UserChartDetailListItem struct {
- ChartInfoId int `description:"图表ID"`
- CollectTime string `description:"收藏时间"`
- }
|