Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_4.4

xingzai 3 years ago
parent
commit
b605f1df1f
6 changed files with 42 additions and 9 deletions
  1. 11 0
      controllers/article.go
  2. 5 2
      controllers/config.go
  3. 18 0
      models/config.go
  4. 3 2
      models/industrial_management.go
  5. 4 4
      services/article.go
  6. 1 1
      utils/config.go

+ 11 - 0
controllers/article.go

@@ -846,12 +846,23 @@ func (this *ArticleController) Pdfwatermark() {
 		br.Ret = 408
 		return
 	}
+	uid := user.UserId
 	articleId, err := this.GetInt("ArticleId")
 	if articleId <= 0 {
 		br.Msg = "文章不存在"
 		br.ErrMsg = "文章不存在,文章ID错误"
 		return
 	}
+
+	//缓存校验
+	cacheKey := fmt.Sprint("xygx:apply_record:add:", uid, "ArticleId_", articleId)
+	ttlTime := utils.Rc.GetRedisTTL(cacheKey)
+	if ttlTime > 0 {
+		br.Msg = "下载失败,下载过于频繁"
+		br.ErrMsg = "下载失败,下载过于频繁:mobile" + user.Mobile
+		return
+	}
+	utils.Rc.SetNX(cacheKey, user.Mobile, time.Minute*5)
 	detail := new(models.ArticleDetail)
 	detail, err = models.GetArticleDetailById(articleId)
 	if err != nil {

+ 5 - 2
controllers/config.go

@@ -20,13 +20,16 @@ func (this *ConfigController) BrowseHistoryList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	configCode := "hot_search"
-	detail, err := models.GetConfigByCode(configCode)
+	detail := new(models.CygxConfig)
+	//configCode := "hot_search"
+	//detail, err := models.GetConfigByCode(configCode)
+	hotSearch, err := models.GetHotSearch()
 	if err != nil {
 		br.Msg = "获取数据失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+	detail.ConfigValue = hotSearch
 	resp := new(models.ConfigResp)
 	resp.Item = detail
 	br.Msg = "获取成功!"

+ 18 - 0
models/config.go

@@ -30,3 +30,21 @@ func GetShowSustainable() (count int, err error) {
 	err = o.Raw(sqlCount).QueryRow(&count)
 	return
 }
+
+// 通过报告精选来获取最新的推荐搜索词
+func GetHotSearch() (permission string, err error) {
+	sql := ` SELECT
+	GROUP_CONCAT(DISTINCT s.subject_name  ORDER BY rl.article_sun_id ASC  SEPARATOR ',') AS subject_name 
+FROM
+	cygx_report_selection_log AS rl
+	INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = rl.industrial_subject_id 
+WHERE
+	rl.article_id = (
+	SELECT
+		MAX( article_id ) 
+FROM
+	cygx_report_selection WHERE publish_status = 1)`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&permission)
+	return
+}

+ 3 - 2
models/industrial_management.go

@@ -162,8 +162,9 @@ func GetIndustrialNewArticleDetail(industrialManagementId int) (item *ArticleDet
 FROM
 	cygx_article 
 WHERE
-	article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) 
+	article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? )
 ORDER BY
+	is_report DESC,
 	publish_date DESC 
 	LIMIT 0,1`
 	err = o.Raw(sql, industrialManagementId).QueryRow(&item)
@@ -337,7 +338,7 @@ WHERE
 GROUP BY
 	s.industrial_subject_id 
 ORDER BY
-	sg.create_time DESC 
+	sg.id ASC 
 	LIMIT 4`
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return

+ 4 - 4
services/article.go

@@ -294,7 +294,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetArticleListByApi ErrMsg:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}()
-	url := "https://vmp.hzinsights.com/v2api/articles/mp?take=100&skip=0&publish_status=1"
+	url := "https://vmp.hzinsights.com/v2api/articles/mp?take=100&skip=0&publish_status=2"
 	method := "GET"
 	client := &nhttp.Client{}
 	req, err := nhttp.NewRequest(method, url, nil)
@@ -368,7 +368,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			}
 			item.CreateDate = v.CreateDate
 			item.PublishDate = v.PublishDate
-			item.PublishStatus = v.PublishStatus
+			item.PublishStatus = 1
 			item.Body = v.Content.Body
 			item.Abstract = v.Content.Abstract
 			item.CategoryName = v.Industry.Name
@@ -507,7 +507,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 				updateParams["SubCategoryName"] = v.SubCategoryName
 			}
 			//updateParams["CategoryId"] = v.CategoryId
-			updateParams["PublishStatus"] = v.PublishStatus
+			updateParams["PublishStatus"] = 1
 			updateParams["ExpertBackground"] = expertContentStr
 			updateParams["ExpertNumber"] = expertNumStr
 			updateParams["InterviewDate"] = interviewDateStr
@@ -538,7 +538,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			item.CategoryName = v.CategoryName
 			item.SubCategoryName = v.SubCategoryName
 			item.CategoryId = v.CategoryId
-			item.PublishStatus = v.PublishStatus
+			item.PublishStatus = 1
 			item.ExpertBackground = expertContentStr
 			item.ExpertNumber = expertNumStr
 			item.InterviewDate = interviewDateStr

+ 1 - 1
utils/config.go

@@ -120,7 +120,7 @@ func init() {
 		WxPublicAppId = "wx4a844c734d8c8e56"
 		WxPublicAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
 		WxPublicId = "gh_b67e0049fb8c"
-		IndexName = "cygx_article_v0107"
+		IndexName = "cygx_article_v0125"
 
 		//接收附件邮箱
 		EmailTechnology = "mlluo@hzinsights.com;jxu@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com"    //科技行业专家邮箱