瀏覽代碼

Merge branch 'cygx_12.0' into debug

ziwen 1 年之前
父節點
當前提交
74d035653e
共有 4 個文件被更改,包括 26 次插入5 次删除
  1. 3 0
      controllers/user.go
  2. 3 0
      controllers/yanxuan_special.go
  3. 1 0
      models/report.go
  4. 19 5
      models/user.go

+ 3 - 0
controllers/user.go

@@ -587,6 +587,9 @@ func (this *UserController) CollectList() {
 		if item.ArticleTypeId == -1 {
 			list[i].ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
 		}
+		if item.MyCollectNum > 0 {
+			list[i].IsCollect = true
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = list

+ 3 - 0
controllers/yanxuan_special.go

@@ -74,6 +74,9 @@ func (this *YanxuanSpecialController) List() {
 			}
 			v.Docs = docs
 		}
+		if v.MyCollectNum > 0 {
+			v.IsCollect = 1
+		}
 	}
 	resp := new(models.SpecialListResp)
 

+ 1 - 0
models/report.go

@@ -1065,6 +1065,7 @@ type ArticleReportBillboardResp struct {
 	ArticleTypeName string `description:"文章类型名称"`
 	IsSpecial       int    `description:"是否为研选专栏"`
 	SpecialTags     string `description:"研选专栏标签"`
+	MyCollectNum    int    `description:"本人是否收藏"`
 	List            []*IndustrialManagementIdInt
 }
 

+ 19 - 5
models/user.go

@@ -31,8 +31,14 @@ type UserDetail struct {
 func GetUserDetailByUserId(userId int) (item *UserDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT *,
-	( SELECT COUNT( 1 ) AS count FROM cygx_article_collect AS a	INNER JOIN cygx_article AS art ON art.article_id = a.article_id  WHERE
-		a.user_id = ? AND art.publish_status = 1 ) AS con_num,
+	( SELECT SUM(count) AS count FROM (
+			SELECT COUNT(1) AS count FROM cygx_article_collect AS a 
+			INNER JOIN cygx_article as art ON art.article_id = a.article_id 
+			WHERE a.user_id=? AND art.publish_status = 1  
+			UNION ALL
+			SELECT COUNT(1) AS count FROM cygx_yanxuan_special_collect AS a
+			INNER JOIN cygx_yanxuan_special as b ON b.id = a.yanxuan_special_id 
+			WHERE a.user_id=? AND b.status = 3) AS c  ) AS con_num,
 	(SELECT	COUNT( 1 ) AS count FROM
 		( SELECT count(*) FROM cygx_article_history_record AS a WHERE a.user_id = ?  GROUP BY a.article_id ) b ) AS history_num ,
 	( SELECT COUNT( 1 ) AS count FROM	cygx_my_schedule AS a INNER JOIN cygx_activity AS art ON art.activity_id = a.activity_id WHERE
@@ -148,8 +154,16 @@ type CheckStatusResp struct {
 }
 
 func GetArticleUserCollectCount(userId int) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id WHERE a.user_id=? AND art.publish_status = 1  `
-	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	sql := `SELECT SUM(count) AS count FROM (
+			SELECT COUNT(1) AS count FROM cygx_article_collect AS a 
+			INNER JOIN cygx_article as art ON art.article_id = a.article_id 
+			WHERE a.user_id=? AND art.publish_status = 1  
+			UNION ALL
+			SELECT COUNT(1) AS count FROM cygx_yanxuan_special_collect AS a
+			INNER JOIN cygx_yanxuan_special as b ON b.id = a.yanxuan_special_id 
+			WHERE a.user_id=? AND b.status = 3) AS c 
+			 `
+	err = orm.NewOrm().Raw(sql, userId, userId).QueryRow(&count)
 	return
 }
 
@@ -172,7 +186,7 @@ func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*Articl
 			INNER JOIN cygx_article as art ON art.article_id = a.article_id
 			WHERE a.user_id=? 
 			UNION ALL
-			SELECT
+	SELECT
 		a.id AS article_id,
 		0 AS category_id,
 		a.title AS title,