|
@@ -446,9 +446,10 @@ func GetCygxArticleHistoryRecordByUser(mobile, email, condition string, startSiz
|
|
|
}
|
|
|
|
|
|
// 用户阅读记录列表 2023-08-02 优化拆分
|
|
|
-func GetCygxArticleHistoryRecordByUserNew(mobile, email, condition string, startSize, pageSize int) (items []*UserInteraction, err error) {
|
|
|
+func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
- sql := ` SELECT
|
|
|
+ var sql string
|
|
|
+ sql += `SELECT
|
|
|
art.title,
|
|
|
art.article_id,
|
|
|
art.article_id_md5,
|
|
@@ -456,17 +457,44 @@ func GetCygxArticleHistoryRecordByUserNew(mobile, email, condition string, start
|
|
|
art.category_name,
|
|
|
r.create_time,
|
|
|
r.stop_time,
|
|
|
- r.source as source_platform
|
|
|
+ r.source AS source_platform,
|
|
|
+ '' AS register_platform,
|
|
|
+ '' AS special_type
|
|
|
FROM
|
|
|
cygx_article_history_record_all AS r
|
|
|
- INNER JOIN cygx_article AS art ON art.article_id = r.article_id
|
|
|
+ INNER JOIN cygx_article AS art ON art.article_id = r.article_id
|
|
|
WHERE
|
|
|
- r.mobile = ? AND is_del = 0 ` + condition + ` OR ( email = ? AND email <>'' AND is_del = 0 ` + condition + ` )
|
|
|
- ORDER BY r.create_time DESC `
|
|
|
+ 1= 1
|
|
|
+ AND is_del = 0 ` + condition
|
|
|
+
|
|
|
+ sql += ` UNION ALL `
|
|
|
+ sql += ` SELECT
|
|
|
+ art.title,
|
|
|
+ art.id AS article_id,
|
|
|
+ '' AS article_id_md5,
|
|
|
+ art.publish_time AS publish_date,
|
|
|
+ '' AS category_name,
|
|
|
+ r.create_time,
|
|
|
+ r.stop_time,
|
|
|
+ r.register_platform AS source_platform,
|
|
|
+ r.register_platform,
|
|
|
+ art.type AS special_type
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_record AS r
|
|
|
+ INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
+ WHERE 1 = 1 ` + condition
|
|
|
+
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, article_id DESC `
|
|
|
if startSize > 0 || pageSize > 0 {
|
|
|
sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
}
|
|
|
- _, err = o.Raw(sql, mobile, email).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|