Browse Source

索引更新

xingzai 3 years ago
parent
commit
5cb2f60cfc
2 changed files with 13 additions and 2 deletions
  1. 12 1
      controllers/article.go
  2. 1 1
      utils/config.go

+ 12 - 1
controllers/article.go

@@ -797,12 +797,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.Second*5)
 	detail := new(models.ArticleDetail)
 	detail, err = models.GetArticleDetailById(articleId)
 	if err != nil {
@@ -847,7 +858,7 @@ func (this *ArticleController) Pdfwatermark() {
 		}
 		defer res.Body.Close()
 		// 获得get请求响应的reader对象
-		reader := bufio.NewReaderSize(res.Body, 32*1024)
+		reader := bufio.NewReaderSize(res.Body, 64*1024)
 		file, err := os.Create(oldFile)
 		if err != nil {
 			br.Msg = "下载失败"

+ 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"    //科技行业专家邮箱