2 Commits a2d95c2ddd ... 4a68e85112

Autor SHA1 Mensaje Fecha
  zhangchuanxing 4a68e85112 Merge branch 'cygx_14.2' of http://8.136.199.33:3000/hongze/hongze_clpt into debug hace 4 días
  zhangchuanxing 914e84e2e7 no message hace 4 días

+ 8 - 0
models/industry_fllow.go

@@ -113,3 +113,11 @@ func GetUserFllowIndustrialList(userId int) (items []*CygxIndustryFllow, err err
 	_, err = o.Raw(sql, userId).QueryRows(&items)
 	return
 }
+
+// UpdateIndustrialManagementTimeLineData   更新时间线关联对应最新文章的数据信息
+func UpdateIndustrialManagementTimeLineData(industrialManagementId int, timeLineData string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industrial_management SET time_line_data = ? WHERE  industrial_management_id = ?   `
+	_, err = o.Raw(sql, timeLineData, industrialManagementId).Exec()
+	return
+}

+ 8 - 0
models/report.go

@@ -32,10 +32,17 @@ type IndustrialManagement struct {
 	Source                 int                  `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
 	MinReportTime          string               `description:"报告最早发布时间"`
+	TimeLineData           string               `description:"时间线所关联最新三篇文章的json数据"`
+	ListTimeLine           []TimeLineReportResp `description:"时间线所关联最新三篇文章列表"`
 	IndustryVideo          *MicroVideoSimpleInfo
 	AuthInfo               *UserPermissionAuthInfo
 }
 
+type TimeLineReportResp struct {
+	Title       string `description:"标题"`
+	PublishDate string `description:"发布时间"`
+}
+
 type MicroVideoSimpleInfo struct {
 	Id                  int    `description:"视频ID"`
 	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
@@ -239,6 +246,7 @@ func GetReportAndproductIndustrylListimg(categoryId, userId, startSize, pageSize
 func GetSearchResourceList(condition string) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
+			m.time_line_data,
 			m.industry_name,
 			m.chart_permission_id,
 			m.industrial_management_id,

+ 8 - 0
services/es_comprehensive.go

@@ -584,6 +584,14 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 		//listIndustrialResourceIds, _ = HandleIndustryList(listIndustrialResourceIds, user, "Hz")
 		for _, v := range listIndustrialResourceIds {
+			if v.TimeLineData == "" {
+				v.ListTimeLine = make([]models.TimeLineReportResp, 0)
+			} else {
+				if err = json.Unmarshal([]byte(v.TimeLineData), &v.ListTimeLine); err != nil {
+					e = errors.New("Unmarshal, Err: " + e.Error())
+					return
+				}
+			}
 			v.Source = 1
 			v.UpdateTime = v.PublishDate
 			mapItems[fmt.Sprint("industrialsourceHz", v.IndustrialManagementId)].IndustrialResource = v

+ 50 - 0
services/industrial_management.go

@@ -1,6 +1,7 @@
 package services
 
 import (
+	"encoding/json"
 	"errors"
 	"fmt"
 	"hongze/hongze_clpt/models"
@@ -446,3 +447,52 @@ func GetCygxIndustryFllowListTypeMapByMobile(mobile string) (mapFollowTypeResp m
 
 	return
 }
+
+//func init() {
+//	IndustrialManagementTimeLineDateList3(78)
+//}
+
+// 时间线关联文章的三条数据
+func IndustrialManagementTimeLineDateList3(industrialManagementId int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("修改行业关注或者取消关注的时候,对于用户全部赛道的影响信息失败"+err.Error(), 2)
+		}
+	}()
+	list, total, e := models.GetTimeLineReportIndustrialListTime(0, industrialManagementId, 0, 3)
+	if e != nil {
+		err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+		return
+	}
+	fmt.Println(total)
+
+	type TimeLineReportItem struct {
+		Title       string `description:"标题"`
+		PublishDate string `description:"发布时间"`
+	}
+	//type TimeLIineData struct {
+	//	ListTimeLine []*TimeLineReportItem
+	//}
+
+	var listData []*TimeLineReportItem
+	for _, v := range list {
+		item := new(TimeLineReportItem)
+		item.Title = v.Title
+		item.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+		listData = append(listData, item)
+	}
+
+	//var listData2 TimeLIineData
+	//listData2.ListTimeLine = listData
+	jsonData, err := json.Marshal(listData)
+	if err != nil {
+		fmt.Println("Error marshaling to JSON:", err)
+		return
+	}
+
+	e = models.UpdateIndustrialManagementTimeLineData(industrialManagementId, string(jsonData))
+	fmt.Println(string(jsonData))
+	fmt.Println(e)
+	return err
+}