Pārlūkot izejas kodu

文章 海外医药零距离 类型 同步错误修改

xingzai 4 gadi atpakaļ
vecāks
revīzija
7561cb6ee9
5 mainītis faili ar 28 papildinājumiem un 8 dzēšanām
  1. 18 1
      controllers/tactics.go
  2. 1 0
      models/article.go
  3. 7 4
      models/tactics.go
  4. 1 1
      services/tactics.go
  5. 1 2
      services/task.go

+ 18 - 1
controllers/tactics.go

@@ -34,6 +34,13 @@ func (this *TacticsController) List() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	categoryId, _ := this.GetInt("CategoryId")
@@ -75,8 +82,9 @@ func (this *TacticsController) List() {
 		br.Msg = "获取帖子总数失败,Err:" + err.Error()
 		return
 	}
+	uid = 42017
 	page = paging.GetPaging(currentIndex, pageSize, total)
-	list, err := models.GetReportTacticsList(condition, pars, startSize, pageSize)
+	list, err := models.GetReportTacticsList(condition, pars, uid, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取帖子数据失败,Err:" + err.Error()
@@ -89,6 +97,15 @@ func (this *TacticsController) List() {
 		//list[i].Abstract = html.UnescapeString(item.Abstract)
 		list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
 	}
+
+	for k, v := range list {
+		fmt.Println(v.Re)
+		if v.Re > 0 {
+			list[k].IsRed = false
+		} else {
+			list[k].IsRed = true
+		}
+	}
 	resp.List = list
 	resp.Paging = page
 	br.Ret = 200

+ 1 - 0
models/article.go

@@ -257,6 +257,7 @@ type ReportArticle struct {
 	SubCategoryName  string `description:"二级分类"`
 	ExpertBackground string `description:"专家背景"`
 	IsRed            bool   `description:"是否标记红点"`
+	Re               int    `description:"阅读数量"`
 }
 
 func GetReportPermission(categoryName string) (item []*ChartPermission, err error) {

+ 7 - 4
models/tactics.go

@@ -1,8 +1,10 @@
 package models
 
 import (
+	"fmt"
 	"rdluck_tools/orm"
 	"rdluck_tools/paging"
+	"strconv"
 	"time"
 )
 
@@ -88,7 +90,7 @@ func GetTacticsList2(endDate string) (list []*Tactics2, err error) {
 			INNER JOIN article_content AS b ON a.id=b.article_id
 			INNER JOIN article_category AS c ON a.id=c.article_id
 			INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
-			WHERE a.publish_status=1  AND a.publish_date>=? AND d.id IN (7,11,28,32,45,47,50,51,52,57,62,64,65,66,67,69,71,74,79,80,84,85,86,87,88,89,90,95) 
+			WHERE a.publish_status=1  AND a.publish_date>=? AND d.id IN (7,11,28,32,45,50,51,52,57,62,64,65,66,67,69,71,74,79,80,84,85,86,87,88,89,90,95,96) 
             AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
 	//IN(85,71)
 	_, err = o.Raw(sql, endDate).QueryRows(&list)
@@ -103,7 +105,7 @@ func GetTacticsListAll2() (list []*Tactics2, err error) {
 			INNER JOIN article_content AS b ON a.id=b.article_id
 			INNER JOIN article_category AS c ON a.id=c.article_id
 			INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
-			WHERE a.publish_status=1  AND d.id IN (7,11,28,32,45,47,50,51,52,57,62,64,65,66,67,69,71,74,79,80,84,85,86,87,88,89,90,95) 
+			WHERE a.publish_status=1  AND d.id IN (7,11,28,32,45,50,51,52,57,62,64,65,66,67,69,71,74,79,80,84,85,86,87,88,89,90,95,96) 
             AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
 	//IN(85,71)
 	_, err = o.Raw(sql).QueryRows(&list)
@@ -115,15 +117,16 @@ type TacticsListResp struct {
 	List   []*ReportArticle
 }
 
-func GetReportTacticsList(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportArticle, err error) {
+func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT *
+	sql := ` SELECT * ,(SELECT COUNT(1) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND  rec.article_id=a.article_id) AS re
                  FROM cygx_article AS a
                 WHERE a.publish_status=1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` ORDER BY publish_date DESC LIMIT ?,? `
+	fmt.Println(sql)
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 1 - 1
services/tactics.go

@@ -401,7 +401,7 @@ func SyncTacticsListAddreport() (err error) {
 			updateParams["ExpertBackground"] = expertContentStr
 			updateParams["ExpertNumber"] = expertNumStr
 			updateParams["InterviewDate"] = interviewDateStr
-			updateParams["IsClass"] = v.IsClass
+			//updateParams["IsClass"] = v.IsClass
 			updateParams["IsSummary"] = v.IsSummary
 			updateParams["IsReport"] = v.IsReport
 			updateParams["ReportType"] = v.ReportType

+ 1 - 2
services/task.go

@@ -14,8 +14,7 @@ func Task() {
 		//syncTacticsList := toolbox.NewTask("syncTacticsList", "0 */5 * * * *", SyncTacticsList)
 		//toolbox.AddTask("syncTacticsList", syncTacticsList)
 		//toolbox.StartTask()
-
-		syncTacticsListAddreport := toolbox.NewTask("syncTacticsListAddreport", "0 16 16 * * *", SyncTacticsListAddreport)
+		syncTacticsListAddreport := toolbox.NewTask("syncTacticsListAddreport", "0 */5 * * * *", SyncTacticsListAddreport)
 		toolbox.AddTask("syncTacticsListAddreport", syncTacticsListAddreport)
 		toolbox.StartTask()
 	}