Browse Source

完善首页-最新、试用申请模板消息

hsun 2 years ago
parent
commit
da8ed47101
5 changed files with 42 additions and 243 deletions
  1. 3 240
      controllers/home.go
  2. 10 0
      controllers/user.go
  3. 1 0
      models/db.go
  4. 26 1
      models/micro_roadshow.go
  5. 2 2
      services/micro_roadshow.go

+ 3 - 240
controllers/home.go

@@ -326,242 +326,6 @@ func (this *BaseHomeController) ListHomePublic() {
 	br.Data = resp
 }
 
-// @Title 首页列表接口v6版本
-// @Description 首页列表接口v6版本
-// @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Param   ChartPermissionId   query   int  true       "品类id,最新传0"
-// @Param   CtagId   query   int  true       "图表子类ID"
-// @Param   ListType   query   int  true       "列表类型,1最新,2 纪要 ,3图表 默认1"
-// @Success 200 {object} models.HomeArtAndChartListResp
-// @router /artAndChart/list [get]
-//func (this *HomeController) ListHomeArtAndChartV6() {
-//	br := new(models.BaseResponse).Init()
-//	defer func() {
-//		this.Data["json"] = br
-//		this.ServeJSON()
-//	}()
-//	user := this.User
-//	if user == nil {
-//		br.Msg = "请登录"
-//		br.ErrMsg = "请登录,用户信息为空"
-//		br.Ret = 408
-//		return
-//	}
-//	pageSize, _ := this.GetInt("PageSize")
-//	currentIndex, _ := this.GetInt("CurrentIndex")
-//	chartPermissionId, _ := this.GetInt("ChartPermissionId")
-//	ctagId, _ := this.GetInt("CtagId")
-//	listType, _ := this.GetInt("ListType")
-//
-//	var startSize int
-//	if pageSize <= 0 {
-//		pageSize = utils.PageSize20
-//	}
-//	if currentIndex <= 0 {
-//		currentIndex = 1
-//	}
-//	if listType <= 0 {
-//		listType = 1
-//	}
-//	startSize = paging.StartIndex(currentIndex, pageSize)
-//
-//	var condition string
-//	var pars []interface{}
-//	var total, chartTotal int
-//	resp := new(models.HomeArtAndChartListResp)
-//	page := paging.GetPaging(currentIndex, pageSize, total)
-//	resp.HaveResearch = true
-//	var chartList []*models.HomeChartListResp
-//	var err error
-//	if listType == 1 {
-//		if currentIndex <= 2 {
-//			listCtagId := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
-//			var chartIds string
-//			for _, v := range listCtagId {
-//				chartListTwo, err := models.GetChartList(`AND  ctag_id = `+strconv.Itoa(v), pars, 0, 2)
-//				if err != nil {
-//					br.Msg = "获取信息失败"
-//					br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
-//					return
-//				}
-//				for _, vChart := range chartListTwo {
-//					chartIds += strconv.Itoa(vChart.ChartId) + ","
-//				}
-//			}
-//			chartIds = strings.TrimRight(chartIds, ",")
-//			condition += ` AND chart_id IN (` + chartIds + `) `
-//			chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
-//			if err != nil {
-//				br.Msg = "获取信息失败"
-//				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
-//				return
-//			}
-//
-//		}
-//	} else if listType == 3 {
-//		if chartPermissionId > 0 {
-//			condition += ` AND a.ptag_id =? `
-//			pars = append(pars, chartPermissionId)
-//		}
-//		if ctagId > 0 {
-//			condition += ` AND a.ctag_id =? `
-//			pars = append(pars, ctagId)
-//		}
-//		chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
-//		if err != nil {
-//			br.Msg = "获取信息失败"
-//			br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
-//			return
-//		}
-//		chartTotal, err = models.GetChartCount(condition, pars)
-//		if err != nil {
-//			br.Msg = "获取信息失败"
-//			br.Msg = "获取帖子总数失败,Err:" + err.Error()
-//			return
-//		}
-//	}
-//	for k, v := range chartList {
-//		if v.PtagName != "" {
-//			chartList[k].CtagNamePc = v.PtagName
-//		}
-//		if v.CtagName != "" {
-//			chartList[k].CtagNamePc += "," + v.CtagName
-//		}
-//		if v.PtagNameTwo != "" {
-//			chartList[k].CtagNamePc += "," + v.PtagNameTwo
-//		}
-//		if v.CtagNameTwo != "" {
-//			chartList[k].CtagNamePc += "," + v.CtagNameTwo
-//		}
-//		chartList[k].IsNeedJump = true
-//		chartList[k].Source = 2
-//	}
-//	resp.ChartList = chartList
-//
-//	if listType != 3 {
-//		userType, _, err := services.GetUserType(user.CompanyId)
-//		if err != nil {
-//			br.Msg = "获取信息失败"
-//			br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
-//			return
-//		}
-//		condition = ` AND is_summary = 1  `
-//		if chartPermissionId > 0 {
-//			categoryId, err := models.GetCategoryId(chartPermissionId)
-//			if err != nil && err.Error() != utils.ErrNoRow() {
-//				br.Msg = "获取信息失败"
-//				br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
-//				return
-//			}
-//			categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
-//			if err != nil {
-//				br.Msg = "获取信息失败"
-//				br.ErrMsg = "获取信息失败,Err:" + err.Error()
-//				return
-//			}
-//			if userType == 1 && strings.Contains(categoryinfo.PermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
-//				resp.HaveResearch = false
-//				resp.Paging = page
-//				br.Ret = 200
-//				br.Success = true
-//				br.Msg = "获取成功"
-//				br.Data = resp
-//				return
-//			}
-//			page = paging.GetPaging(currentIndex, pageSize, total)
-//			if categoryId != "" {
-//				condition += ` AND category_id IN(` + categoryId + `)`
-//				//condition += ` OR ( category_name  LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%' AND publish_status = 1 AND is_summary = 1 )`
-//			} else {
-//				condition += ` AND  category_name   LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
-//			}
-//		}
-//		//永续客户无法查看研选分类的内容
-//		if userType == 1 {
-//			condition += ` AND  category_name  NOT LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
-//		}
-//		total, err = models.GetHomeCount(condition, pars)
-//		if err != nil {
-//			br.Msg = "获取信息失败"
-//			br.Msg = "获取帖子总数失败,Err:" + err.Error()
-//			return
-//		}
-//
-//		list, err := models.GetHomeList(condition, pars, startSize, pageSize)
-//		if err != nil {
-//			br.Msg = "获取信息失败"
-//			br.Msg = "获取帖子数据失败,Err:" + err.Error()
-//			return
-//		}
-//		//研选的五张图片
-//		detailResearch, err := models.GetConfigByCode("category_research_img_url")
-//		if err != nil {
-//			br.Msg = "获取数据失败"
-//			br.ErrMsg = "获取数据研选分类图片失败,Err:" + err.Error()
-//			return
-//		}
-//		researchList := strings.Split(detailResearch.ConfigValue, "{|}")
-//		//对应分类的所图片
-//		detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
-//		if err != nil {
-//			br.Msg = "获取数据失败"
-//			br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
-//			return
-//		}
-//		categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
-//		mapCategoryUrl := make(map[string]string)
-//		var categoryId string
-//		var imgUrlChart string
-//		for _, v := range categoryUrlList {
-//			vslice := strings.Split(v, "_")
-//			categoryId = vslice[0]
-//			imgUrlChart = vslice[len(vslice)-1]
-//			mapCategoryUrl[categoryId] = imgUrlChart
-//		}
-//
-//		for k, v := range list {
-//			item := list[k]
-//			//如果文章一开始的内容是图片,优先展示第一张图片
-//			imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
-//			newBody, _ := services.GetReportContentTextSubByarticle(item.Body, item.Annotation, item.ArticleId)
-//			list[k].Body = newBody
-//			if imgurl != "" {
-//				list[k].BodyHtml = imgurl
-//			}
-//			list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDateTimeNoSecond) //时间字符串格式转时间格式
-//			if strings.Contains(item.CategoryName, utils.CHART_PERMISSION_NAME_YANXUAN) {
-//				list[k].IsResearch = true
-//			}
-//			if item.Pv > 999 {
-//				list[k].Pv = 999
-//			}
-//			//如果是研选系列的任意取五张图片的中的一张
-//			if v.CategoryId == "0" {
-//				knum := v.ArticleId % 5
-//				list[k].ImgUrlPc = researchList[knum]
-//			} else {
-//				list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
-//			}
-//			if list[k].ArticleId < utils.SummaryArticleId {
-//				list[k].HttpUrl = utils.StrategyPlatform + strconv.Itoa(v.ArticleId)
-//				list[k].IsNeedJump = true
-//			}
-//			list[k].Source = 1
-//		}
-//		resp.List = list
-//	}
-//	if chartTotal > total {
-//		total = chartTotal
-//	}
-//	page = paging.GetPaging(currentIndex, pageSize, total)
-//	resp.Paging = page
-//	br.Ret = 200
-//	br.Success = true
-//	br.Msg = "获取成功"
-//	br.Data = resp
-//}
-
 // @Title 首页/搜索头部导航接口
 // @Description 首页/搜索头部导航接口
 // @Param   SearchPage  query  int  false  "是否为搜索页面"
@@ -612,9 +376,8 @@ func (this *HomeController) HeaderTab() {
 	br.Data = resp
 }
 
-
-// @Title 首页列表接口v6版本
-// @Description 首页列表接口v6版本
+// @Title 首页列表接口v7.6版本
+// @Description 首页列表接口v7.6版本
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartPermissionId   query   int  true       "品类id,最新传0"
@@ -778,7 +541,7 @@ func (this *HomeController) ListHomeArtAndChart() {
 		// 7.6-与音频作联合查询, 整体进行发布时间的排序(代码写的嘎嘎烂, 将就着用吧=_=!)
 		if listType == 1 {
 			var unionPars []interface{}
-			unionList, unionTotal, e := services.GetHomeNewestList(0, 0, condition, unionPars)
+			unionList, unionTotal, e := services.GetHomeNewestList(user.UserId, user.CompanyId, startSize, pageSize, condition, unionPars)
 			if e != nil {
 				br.Msg = "获取信息失败"
 				br.Msg = "获取纪要音频联合列表失败, Err: " + e.Error()

+ 10 - 0
controllers/user.go

@@ -802,6 +802,7 @@ func (this *UserController) ApplyTryOut() {
 	var title string
 	tryType := req.TryType
 	detailId := req.DetailId
+
 	if tryType == "Article" {
 		detail, err := models.GetArticleDetailById(detailId)
 		if err != nil {
@@ -818,6 +819,15 @@ func (this *UserController) ApplyTryOut() {
 			return
 		}
 		title = detail.ActivityName
+	} else {
+		// 7.6-微路演视频
+		microVideo, e := models.GetMicroRoadshowVideoById(detailId)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(detailId)
+			return
+		}
+		title = microVideo.VideoName
 	}
 
 	fmt.Println(title)

+ 1 - 0
models/db.go

@@ -119,6 +119,7 @@ func init() {
 		new(CygxActivityVoiceHistory),
 		new(CygxThreeApiLog),
 		new(CygxMicroRoadshowVideoHistory),
+		new(MicroRoadshowVideo),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 26 - 1
models/micro_roadshow.go

@@ -228,4 +228,29 @@ func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err err
 	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
 	_, err = o.Raw(sql, playSeconds, lastId).Exec()
 	return
-}
+}
+
+// MicroRoadshowVideo 微路演视频
+type MicroRoadshowVideo struct {
+	VideoId             int       `orm:"column(video_id);pk" description:"视频ID"`
+	VideoName           string    `description:"视频标题"`
+	ChartPermissionId   int       `description:"行业ID"`
+	ChartPermissionName string    `description:"行业名称"`
+	IndustryId          int       `description:"产业ID"`
+	IndustryName        string    `description:"产业名称"`
+	PublishStatus       int       `description:"发布状态:0-未发布;1-已发布"`
+	ModifyDate          time.Time `description:"更新时间"`
+	PublishDate         time.Time `description:"发布时间"`
+	VideoCounts         int       `description:"视频播放量"`
+	VideoDuration       int       `description:"视频时长"`
+	VideoUrl            string    `description:"视频地址"`
+	CreateTime          time.Time `description:"创建时间"`
+	ImgUrl              string    `description:"背景图链接"`
+}
+
+// GetMicroRoadshowVideoById 主键获取微路演视频
+func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}

+ 2 - 2
services/micro_roadshow.go

@@ -195,9 +195,9 @@ func GetMicroRoadShowDefaultImgConfig() (audioMap, videoMap map[int]string, err
 }
 
 // GetHomeNewestList 获取首页最新列表
-func GetHomeNewestList(userId, companyId int, condition string, pars []interface{}) (resp []*models.HomeArticle, total int, err error) {
+func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition string, pars []interface{}) (resp []*models.HomeArticle, total int, err error) {
 	resp = make([]*models.HomeArticle, 0)
-	unionList, e := models.GetHomeNewestListUnionList(condition, pars, 0, 20)
+	unionList, e := models.GetHomeNewestListUnionList(condition, pars, startSize, pageSize)
 	if e != nil {
 		err = errors.New("获取首页最新列表失败")
 		return