|
@@ -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 = "下载失败"
|