Browse Source

搜索资源包下新增产业视频

xiexiaoyuan 2 years ago
parent
commit
2a6776a6c1
3 changed files with 63 additions and 18 deletions
  1. 48 5
      controllers/report.go
  2. 4 3
      models/micro_roadshow.go
  3. 11 10
      models/report.go

+ 48 - 5
controllers/report.go

@@ -253,13 +253,13 @@ func (this *ReportController) IndustryList() {
 
 	//查询产业视频
 	industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
-	var industrialManagementIds string
+	var industrialManagementIds []int
 	for _, v := range list {
 		if v.IndustrialManagementId > 0 {
-			industrialManagementIds += strconv.Itoa(v.IndustrialManagementId) +","
+			industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
 		}
 	}
-	if industrialManagementIds != "" {
+	if len(industrialManagementIds) >0 {
 		// 获取默认图配置
 		_, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
 		if e != nil {
@@ -267,8 +267,6 @@ func (this *ReportController) IndustryList() {
 			br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
 			return
 		}
-
-		industrialManagementIds = strings.Trim(industrialManagementIds, ",")
 		videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialManagementIds)
 		if err != nil {
 			br.Msg = "产业视频列表失败"
@@ -2710,9 +2708,53 @@ func (this *ReportController) SearchReportAndResource() {
 			listYxResource[k].IsFollw = true
 		}
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
+
 	}
 
 	if len(industrialIdArr) > 0 {
+		//查询产业视频
+		industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
+		// 获取默认图配置
+		_, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			br.Msg = "获取视频默认配置图失败"
+			br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
+			return
+		}
+		videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
+		if err != nil {
+			br.Msg = "产业视频列表失败"
+			br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
+			return
+		}
+		for _, v := range videoList {
+			tmp := &models.MicroVideoSimpleInfo{
+				Id:            v.VideoId,
+				Title:         "5min逻辑【"+v.IndustryName+"】解析",
+				ResourceUrl:   v.VideoUrl,
+				BackgroundImg: v.ImgUrl,
+				PlaySeconds:   v.VideoDuration,
+			}
+			if tmp.BackgroundImg == "" {
+				tmp.BackgroundImg = videoMap[v.ChartPermissionId]
+			}
+			industrialVideoMap[v.IndustryId] = tmp
+		}
+
+		for k, v := range listYxResource {
+			//展示产业视频
+			if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
+				listYxResource[k].IndustryVideo = video
+			}
+		}
+
+		for k, v := range listHzResource {
+			//展示产业视频
+			if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
+				listHzResource[k].IndustryVideo = video
+			}
+		}
+
 		//合并产业关联的标的
 		listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
 		if err != nil {
@@ -2735,6 +2777,7 @@ func (this *ReportController) SearchReportAndResource() {
 				}
 			}
 		}
+
 	}
 
 	resp := new(models.SearchReportAndResourceResp)

+ 4 - 3
models/micro_roadshow.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -290,9 +291,9 @@ func UpdateCygxActivityVideoCounts(activityId int) (err error) {
 }
 
 // GetMicroRoadshowVideoByIndustryIds 根据行业ID查询产业视频列表
-func GetMicroRoadshowVideoByIndustryIds(industryIds string) (list []*MicroRoadshowVideo, err error) {
-	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (`+industryIds+`)`
-	_, err = orm.NewOrm().Raw(sql).QueryRows(&list)
+func GetMicroRoadshowVideoByIndustryIds(industrialIdArr []int) (list []*MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)   `
+	_, err = orm.NewOrm().Raw(sql, industrialIdArr).QueryRows(&list)
 	return
 }
 

+ 11 - 10
models/report.go

@@ -391,16 +391,17 @@ func GetArticleCollectionList(condition string, userId int) (items []*ArticleCol
 
 //用户收藏榜start
 type IndustrialManagementHotResp struct {
-	IndustrialManagementId int                  `orm:"column(industrial_management_id);pk" description:"产业id"`
-	IndustryName           string               `description:"产业名称"`
-	IsFollw                bool                 `description:"是否关注"`
-	FllowNum               int                  `description:"关注数量"`
-	IsNew                  bool                 `description:"是否新标签"`
-	IsHot                  bool                 `description:"是否新标签"`
-	PublishDate            string               `description:"发布时间"`
-	ArticleReadNum         int                  `description:"文章阅读数量"`
-	Source                 int                  `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
-	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
+	IndustrialManagementId int                   `orm:"column(industrial_management_id);pk" description:"产业id"`
+	IndustryName           string                `description:"产业名称"`
+	IsFollw                bool                  `description:"是否关注"`
+	FllowNum               int                   `description:"关注数量"`
+	IsNew                  bool                  `description:"是否新标签"`
+	IsHot                  bool                  `description:"是否新标签"`
+	PublishDate            string                `description:"发布时间"`
+	ArticleReadNum         int                   `description:"文章阅读数量"`
+	Source                 int                   `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	IndustrialSubjectList  []*IndustrialSubject  `description:"标的列表"`
+	IndustryVideo          *MicroVideoSimpleInfo `description:"产业视频"`
 }
 
 type IndustrialManagementHotListResp struct {