Browse Source

搜索new标签

ziwen 2 years ago
parent
commit
f11afd29dd
2 changed files with 16 additions and 0 deletions
  1. 14 0
      controllers/report.go
  2. 2 0
      models/report.go

+ 14 - 0
controllers/report.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"errors"
 	"fmt"
 	"github.com/medivhzhan/weapp/v2"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -2731,7 +2732,20 @@ func (this *ReportController) SearchReportAndResource() {
 		return
 	}
 	industrialIdArr := make([]int, 0)
+	nowTime := time.Now().Local()
+	threeMonBefore := nowTime.AddDate(0, -3, 0)
 	for k, v := range listHzResource {
+		// 关联报告发布时间均在3个月内则标记New
+		if v.MinReportTime != "" {
+			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if e != nil {
+				err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+				return
+			}
+			if t.After(threeMonBefore) {
+				listHzResource[k].IsNew = true
+			}
+		}
 		listHzResource[k].Source = 1
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listHzResource[k].IsFollw = true

+ 2 - 0
models/report.go

@@ -405,6 +405,7 @@ type IndustrialManagementHotResp struct {
 	IsNew                  bool                  `description:"是否新标签"`
 	IsHot                  bool                  `description:"是否新标签"`
 	PublishDate            string                `description:"发布时间"`
+	MinReportTime          string               `description:"报告最早发布时间"`
 	ArticleReadNum         int                   `description:"文章阅读数量"`
 	Source                 int                   `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	IndustrialSubjectList  []*IndustrialSubject  `description:"标的列表"`
@@ -725,6 +726,7 @@ func GetSearchResourceList(condition string, startSize, pageSize int) (items []*
 			m.industry_name,
 			m.industrial_management_id,
  			MAX( a.publish_date ) as publish_date_order,
+			MIN(a.publish_date) AS min_report_time,
 			date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date 
 		FROM
 			cygx_industrial_management AS m