Browse Source

查研观向8.8

xingzai 2 years ago
parent
commit
890321c46c
3 changed files with 218 additions and 0 deletions
  1. 106 0
      controllers/chart.go
  2. 103 0
      controllers/report_billboard.go
  3. 9 0
      routers/commentsRouter.go

+ 106 - 0
controllers/chart.go

@@ -399,3 +399,109 @@ func (this *ChartController) ChartTop() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 季度列表
+// @Description 季度列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.HomeChartListItem
+// @router /jidu [get]
+func (this *ChartController) Jidu() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	mobile := user.Mobile
+	uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	resp := new(models.HomeChartListItem)
+	if mobile == "" {
+		page := paging.GetPaging(currentIndex, pageSize, 0)
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		resp.IsBindingMobile = false
+		return
+	} else {
+		resp.IsBindingMobile = true
+	}
+	var listCollection []*models.HomeChartListResp
+	var total int
+	var err error
+	chartUserTokenByMobile, _ := services.GetUserTokenByMobile(mobile)
+	chartIds := "5424,5422,5423,5426"
+	if chartUserTokenByMobile != "" {
+		var condition string
+		var pars []interface{}
+		condition = ` AND a.chart_id IN (` + chartIds + `) `
+		total, err = models.GetChartCollentCount(condition, pars)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.Msg = "获取帖子总数失败,Err:" + err.Error()
+			return
+		}
+		listCollection, err = models.GetChartListCollection(chartIds, uid, startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.Msg = "获取信息失败,GetChartListCollection Err:" + err.Error()
+			return
+		}
+	} else {
+		total, err = models.GetChartCountByUser(uid)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.Msg = "获取总数失败,Err:" + err.Error()
+			return
+		}
+		listCollection, err = models.GetChartListCollectionWithCygx(uid, startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.Msg = "获取信息失败,GetChartListCollection Err:" + err.Error()
+			return
+		}
+	}
+	for k, v := range listCollection {
+		if v.NumTop > 0 {
+			listCollection[k].IsTop = true
+		}
+		listCollection[k].Source = 2
+		if v.PtagName != "" {
+			listCollection[k].CtagNamePc = v.PtagName
+		}
+		if v.CtagName != "" {
+			listCollection[k].CtagNamePc += "," + v.CtagName
+		}
+		if v.PtagNameTwo != "" {
+			listCollection[k].CtagNamePc += "," + v.PtagNameTwo
+		}
+		if v.CtagNameTwo != "" {
+			listCollection[k].CtagNamePc += "," + v.CtagNameTwo
+		}
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = listCollection
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 103 - 0
controllers/report_billboard.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"time"
 )
@@ -148,6 +149,108 @@ func (this *ReportBillboardController) FllowList() {
 		list[k].PermissionName = permissionMap[v.ChartPermissionId]
 	}
 
+	//查询产业视频
+	industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
+	var industrialManagementIds []int
+	for _, v := range list {
+		if v.IndustrialManagementId > 0 {
+			industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+		}
+	}
+
+	// 用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+	mapUPdateTime := make(map[int]string)
+
+	if len(industrialManagementIds) > 0 {
+		// 获取默认图配置
+		_, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			br.Msg = "获取视频默认配置图失败"
+			br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
+			return
+		}
+		videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialManagementIds)
+		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,
+				DetailImgUrl:        v.DetailImgUrl,
+				ChartPermissionId:   v.ChartPermissionId,
+				ChartPermissionName: v.ChartPermissionName,
+			}
+			if tmp.BackgroundImg == "" {
+				tmp.BackgroundImg = videoMap[v.ChartPermissionId]
+			}
+			industrialVideoMap[v.IndustryId] = tmp
+		}
+		//获取这些产业下最新更新的文章
+		listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialManagementIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listUpdateTime {
+			mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
+		}
+
+		//时间线的更新时间
+		//	maptimelineUPdateTime := make(map[int]string)
+		listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialManagementIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listtimelinePublishdate {
+			if mapUPdateTime[v.IndustrialManagementId] != "" {
+				if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
+				}
+			}
+		}
+	}
+
+	for k, v := range list {
+		//展示产业视频
+		if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
+			//控制用户权限
+			// 权限
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == services.UserPermissionOperationModeCall {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+				video.ResourceUrl = ""
+			}
+			list[k].AuthInfo = au
+			list[k].IndustryVideo = video
+		}
+	}
+
 	page := paging.GetPaging(1, topNum, len(list))
 	resp := new(models.IndustrialManagementList)
 	resp.List = list

+ 9 - 0
routers/commentsRouter.go

@@ -565,6 +565,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartController"],
+        beego.ControllerComments{
+            Method: "Jidu",
+            Router: `/jidu`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartController"],
         beego.ControllerComments{
             Method: "Collection",