123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "hongze/hongze_clpt/utils"
- "time"
- )
- type CygxArticleHistoryResp struct {
- Pv int `description:"阅读PV"`
- ArticleId int `description:"文章id"`
- Num int `description:"数量"`
- }
- // ArticleTopHistoryRecord 报告阅读飙升榜
- type ArticleTopHistoryRecord struct {
- Id int `orm:"column(id);pk"`
- ArticleId int `description:"文章ID"`
- Title string `description:"文章标题"`
- PublishDate string `description:"发布日期"`
- ChartPermissionId int `description:"行业ID"`
- PermissionName string `description:"行业名称"`
- Pv int `description:"PV"`
- CreateTime time.Time `description:"创建时间"`
- }
- // 获取用户阅读记录
- func GetUserToArticleCount(uid, articleId int) (count int, err error) {
- sqlCount := `SELECT COUNT(1) AS count FROM cygx_article_history_record WHERE user_id=? AND article_id=? `
- o := orm.NewOrm()
- err = o.Raw(sqlCount, uid, articleId).QueryRow(&count)
- return
- }
- // 获取用户阅读记录
- func GetUserToArticleHistory(uid int, articleIdArr []int) (items []*CygxArticleHistoryResp, err error) {
- arrLen := len(articleIdArr)
- if arrLen == 0 {
- return
- }
- sql := `SELECT
- article_id
- FROM
- cygx_article_history_record
- WHERE
- 1 = 1
- AND user_id = ?
- AND article_id IN (` + utils.GetOrmInReplace(len(articleIdArr)) + `)
- GROUP BY
- article_id `
- o := orm.NewOrm()
- _, err = o.Raw(sql, uid, articleIdArr).QueryRows(&items)
- return
- }
- // GetTopReadRecordArticleListByCondition 获取阅读量排行榜
- func GetTopReadRecordArticleListByCondition(limit int, condition string, pars []interface{}) (list []*ArticleListResp, err error) {
- sql := `SELECT
- a.title,
- a.article_id,
- a.publish_date,
- a.annotation,
- a.abstract,
- a.article_type_id,
- m.chart_permission_name,
- a.category_id
- FROM
- cygx_article_top_history_record as r
- INNER JOIN cygx_article as a ON a.article_id = r.article_id
- INNER JOIN cygx_report_mapping as m ON m.category_id = a.category_id_two`
- if condition != `` {
- sql += condition
- }
- sql += ` GROUP BY a.article_id ORDER BY r.pv DESC, a.publish_date DESC LIMIT ?`
- _, err = orm.NewOrm().Raw(sql, pars, limit).QueryRows(&list)
- return
- }
- // GetTopReadRecordArticleListByConditionYx 获取研选阅读量排行榜
- func GetTopReadRecordArticleListByConditionYx(limit int, condition string, pars []interface{}) (list []*ArticleListResp, err error) {
- sql := `SELECT
- a.article_id,
- a.title,
- a.publish_date,
- a.article_type_id,
- '31' AS chart_permission_id,
- '买方研选' AS permission_name,
- COUNT( 1 ) AS pv
- FROM
- cygx_article_history_record_newpv AS l
- JOIN cygx_article AS a ON a.article_id = l.article_id
- WHERE
- a.publish_status = 1 `
- if condition != `` {
- sql += condition
- }
- sql += ` GROUP BY a.article_id ORDER BY pv DESC, a.publish_date DESC LIMIT ?`
- _, err = orm.NewOrm().Raw(sql, pars, limit).QueryRows(&list)
- return
- }
- type AddStopTimeRep struct {
- ArticleId int `description:"文章ID"`
- StopTime int `description:"停留时间"`
- OutType int `description:"退出方式,1正常退出,2强制关闭"`
- Source string `description:"来源,MOBILE:手机端,PC:电脑端"`
- }
- type ArticleDetailAddStopTimeRep struct {
- HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
- HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
- }
|