xingzai 1 年間 前
コミット
b469c26318
3 ファイル変更80 行追加45 行削除
  1. 7 0
      controllers/article.go
  2. 69 43
      models/user.go
  3. 4 2
      utils/constants.go

+ 7 - 0
controllers/article.go

@@ -142,6 +142,13 @@ func (this *ArticleNoLoginController) Detail() {
 		mfyxUserPermissionTotal := services.GetMfyxUserPermissionTotal(uid)
 		if mfyxUserPermissionTotal == 1 {
 			companyPermission += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
+			companyPermission += "," + utils.MAI_FANG_YAN_XUAN_NAME
+			//permissionNameArr = append(permissionNameArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN)
+			//permissionNameArr = append(permissionNameArr, utils.MAI_FANG_YAN_XUAN_NAME)
+		}
+		//如果有研选订阅的权限,那么就拼接一个 买方研选的权限做校验
+		if strings.Contains(companyPermission, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
+			companyPermission += "," + utils.MAI_FANG_YAN_XUAN_NAME
 		}
 		detail, err = models.GetArticleDetailById(articleId)
 		if err != nil {

+ 69 - 43
models/user.go

@@ -380,59 +380,85 @@ func GetArticleUserCollectCount(userId int) (count int, err error) {
 	return
 }
 
+//art.article_id,
+//art.article_type_id,
+//art.title,
+//art.publish_date,
+//'' AS company_tags,
+//'' AS industry_tags,
+//art.department_id,
+//d.nick_name,
+//0 AS is_special,
+//0 as pv,
+//0 as collect_num,
+//a.create_time
+//FROM
+//cygx_article AS art
+//INNER JOIN cygx_article_history_record_newpv AS a ON art.article_id = a.article_id
+//INNER JOIN cygx_article_department AS d ON d.department_id = art.department_id
+//WHERE
+//a.user_id = ?
+//AND a.create_time >= ?
+//AND art.article_type_id > 0
+//GROUP BY
+//art.article_id UNION ALL
+//SELECT
+//art.id AS article_id,
+//- 1 AS article_type_id,
+//art.title,
+//art.publish_time AS publish_date,
+//art.company_tags AS company_tags,
+//art.industry_tags AS industry_tags,
+//d.id AS department_id,
+//d.nick_name,
+//1 AS is_special,
+//art.pv,
+//art.article_collect_num as collect_num,
+//a.create_time
+
 func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
 	sql := `SELECT 
-		a.article_id,
-		art.category_id,
-		art.title,
-		'' AS publish_date,
-		'' AS nick_name,
-		0 AS article_type_id,
-		'' AS article_type_name,
-		0 AS is_special_int,
-		'' AS special_tags,
-		0 AS pv,
-		0 AS collect_num,
-		0 AS my_collect_num,
-		0 AS special_type,
-		a.user_id AS user_id,
-		'' AS company_tag_str, 
-		'' AS industry_tag_str, 
-		0 AS special_column_id,
-		a.create_time AS create_time 
-			FROM cygx_article_collect AS a 
-			INNER JOIN cygx_article as art ON art.article_id = a.article_id
+			art.article_id,
+			art.article_type_id,
+			art.title,
+			art.publish_date,
+			'' AS company_tags,
+			'' AS industry_tags,
+			art.department_id,
+			d.nick_name,
+			0 AS is_special,
+			0 as pv,
+			0 as collect_num,
+			a.create_time
+			FROM
+			cygx_article AS art 
+			INNER JOIN cygx_article_collect as a ON art.article_id = a.article_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = art.department_id
 			WHERE a.user_id=? 
 			AND  art.article_type_id  > 0 
 			UNION ALL
 	SELECT
-		a.id AS article_id,
-		0 AS category_id,
-		a.title AS title,
-		date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
-		b.nick_name AS nick_name,
-		-1 AS article_type_id,
-		'' AS article_type_name,
-		1 AS is_special_int,
-		a.tags AS special_tags,
-		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
-		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
-		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
-		a.type AS special_type,
-		a.user_id AS user_id,
-		a.company_tags AS company_tag_str, 
-		a.industry_tags AS industry_tags_str, 
-		b.id AS special_column_id,
-		c.create_time AS create_time 
+			art.id AS article_id,
+			- 1 AS article_type_id,
+			art.title,
+			art.publish_time AS publish_date,
+			art.company_tags AS company_tags,
+			art.industry_tags AS industry_tags,
+			b.id AS department_id,
+			b.nick_name,
+			1 AS is_special,
+			art.pv,
+			art.article_collect_num as collect_num,
+			c.create_time
 	FROM
-	cygx_yanxuan_special AS a
-	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
-	JOIN cygx_yanxuan_special_collect AS c ON a.id = c.yanxuan_special_id
+	cygx_yanxuan_special AS art
+	JOIN cygx_yanxuan_special_author AS b ON art.user_id = b.user_id
+	JOIN cygx_yanxuan_special_collect AS c ON art.id = c.yanxuan_special_id
 	WHERE
-	1 = 1  AND a.status = 3	AND c.user_id=? 		
+	1 = 1  AND art.status = 3	AND c.user_id=? 		
 	ORDER BY create_time DESC 
 LIMIT ?,? `
-	_, err = orm.NewOrm().Raw(sql, userId, userId, userId, startSize, pageSize).QueryRows(&items)
+	_, err = orm.NewOrm().Raw(sql, userId, userId, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 4 - 2
utils/constants.go

@@ -73,8 +73,10 @@ const (
 	CE_LUE_NAME                      string = "策略"
 	CE_LUE_ID                        int    = 23
 	CHART_PERMISSION_NAME_YANXUAN    string = "研选"
-	CHART_PERMISSION_NAME_MF_YANXUAN string = "买方研选"
-	CHART_PERMISSION_ID_YANXUAN      int    = 31
+	MAI_FANG_YAN_XUAN_NAME           string = "买方研选"
+	CHART_PERMISSION_NAME_MF_YANXUAN string = "研选订阅"
+	CHART_PERMISSION_ID_YANXUAN      int    = 31 //权限研选订阅id
+	YAN_XUAN_KOU_DIAN_BAO_ID         int    = 52 //研选扣点包ID
 	YI_YAO_NAME                      string = "医药"
 	YI_YAO_OTHER_IMG                 string = "https://hzstatic.hzinsights.com/static/temp/20221118202211/20221118/qzPm61bVf40Je7c5iL1s4CbrDcpv.png" //医药其它图片
 	YI_YAO_ID                        int    = 22