浏览代码

产业分类所对应的行业图片

xingzai 3 年之前
父节点
当前提交
11149d9a71
共有 5 个文件被更改,包括 46 次插入16 次删除
  1. 26 1
      controllers/report.go
  2. 13 4
      models/report_mapping.go
  3. 4 3
      models/tactics.go
  4. 2 7
      services/tactics.go
  5. 1 1
      services/task.go

+ 26 - 1
controllers/report.go

@@ -360,8 +360,32 @@ func (this *ReportController) List() {
 		br.Msg = "请输入产业ID"
 		return
 	}
+	//获取该产业下所对应的行业图片
+	detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
+	if errCategory != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
+		return
+	}
+	//对应行业的图片
+	detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+		return
+	}
+	chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
+	mapChartPermission := make(map[string]string)
+	var permissionName string
+	var imgUrlChartPermission string
+	for _, v := range chartPermissionUrlList {
+		vslice := strings.Split(v, "_")
+		permissionName = vslice[0]
+		imgUrlChartPermission = vslice[len(vslice)-1]
+		mapChartPermission[permissionName] = imgUrlChartPermission
+	}
 
-	total, err := models.GetReportIndustrialCount(categoryId, industrialManagementId)
+	total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
@@ -408,6 +432,7 @@ func (this *ReportController) List() {
 		}
 		list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
 	}
+	resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 	resp.List = list
 	resp.Paging = page
 	br.Ret = 200

+ 13 - 4
models/report_mapping.go

@@ -5,10 +5,11 @@ import (
 )
 
 type ReportMapping struct {
-	CategoryId      int    `description:"分类ID"`
-	SubCategoryName string `description:"主题"`
-	MatchTypeName   string `description:"分类名称"`
-	IsRed           bool   `description:"是否标红"`
+	CategoryId          int    `description:"分类ID"`
+	SubCategoryName     string `description:"主题"`
+	MatchTypeName       string `description:"分类名称"`
+	ChartPermissionName string `description:"行业名称"`
+	IsRed               bool   `description:"是否标红"`
 }
 
 type ReportMappingHome struct {
@@ -111,6 +112,14 @@ func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
 	return
 }
 
+//通过分类ID获取详情
+func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? LIMIT 1`
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}
+
 //判断该分类下最新的文章用户是否阅读
 func CheckThisCategoryNewArticleIsRead(uid, categoryId int) (count int, err error) {
 	o := orm.NewOrm()

+ 4 - 3
models/tactics.go

@@ -108,9 +108,10 @@ func GetTacticsListAll2() (list []*Tactics2, err error) {
 }
 
 type TacticsListResp struct {
-	Paging        *paging.PagingItem
-	MatchTypeName string `description:"匹配类型"`
-	List          []*ReportArticle
+	Paging           *paging.PagingItem
+	MatchTypeName    string `description:"匹配类型"`
+	CategoryImgUrlPc string `description:"图片"`
+	List             []*ReportArticle
 }
 
 func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*ReportArticle, err error) {

+ 2 - 7
services/tactics.go

@@ -712,13 +712,6 @@ func BodyAnalysis2(body string) (expertNumStr, expertContentStr, interviewDateSt
 		body = strings.Replace(body, "报告全文():", "", -1)
 	}
 	bodyReturn = body
-	//fmt.Println(bodyReturn)
-	//fmt.Println("_________________")
-	//fmt.Println(fileLink)
-	//body = strings.Replace(body, "报告全文(", "", -1)
-	//body = strings.Replace(body, "PDF格式报告下载.pdf", "", -1)
-	//body = strings.Replace(body, "):", "", -1)
-
 	if len(interviewDateArr) > 0 {
 		interviewDateStr = interviewDateArr[0]
 	}
@@ -752,6 +745,8 @@ func GetSummarytoEs(cont context.Context) (err error) {
 		item.Title = v.Title
 		item.PublishDate = v.PublishDate
 		item.BodyText = bodyText
+		item.CategoryId = strconv.Itoa(v.CategoryId)
+		item.ExpertBackground = v.ExpertBackground
 		EsAddOrEditData(indexName, strconv.Itoa(v.ArticleId), item)
 		fmt.Println(v.ArticleId)
 	}

+ 1 - 1
services/task.go

@@ -76,7 +76,7 @@ func Task() {
 //task.AddTask("editUserOutboundMobile", editUserOutboundMobile)
 
 func CreateIndex() {
-	indexName := "cygx_article_v1" //utils.IndexName
+	indexName := utils.IndexName
 	mappingJson := `{
  "mappings": {
    "dynamic": true,