瀏覽代碼

PDF水印下载限制修改

xingzai 3 年之前
父節點
當前提交
6c4cb0dadb
共有 5 個文件被更改,包括 42 次插入23 次删除
  1. 35 19
      controllers/activity.go
  2. 1 1
      controllers/article.go
  3. 1 0
      models/article.go
  4. 1 0
      models/tactics.go
  5. 4 3
      services/article.go

+ 35 - 19
controllers/activity.go

@@ -259,13 +259,16 @@ func (this *ActivityCoAntroller) ActivityList() {
 
 	//判断客户规模是否属于可见范围的活动
 	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-	if err != nil {
+	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 		return
 	}
-	if companyProduct.Scale != "" {
-		conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+
+	if companyProduct != nil {
+		if companyProduct.Scale != "" {
+			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		}
 	}
 
 	condition += ` AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
@@ -660,16 +663,19 @@ func (this *ActivityCoAntroller) Detail() {
 			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 			return
 		}
+
 		//获取用户的产业规模,判断是否允许可见
 		companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 			return
 		}
-		if companyProduct.Scale != "" {
-			if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
-				noPower = false
+		if companyProduct != nil {
+			if companyProduct.Scale != "" {
+				if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
+					noPower = false
+				}
 			}
 		}
 		if noPower {
@@ -2291,13 +2297,16 @@ func (this *ActivityCoAntroller) LabelTypeList() {
 		}
 		//判断客户规模是否属于可见范围的活动
 		companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 			return
 		}
-		if companyProduct.Scale != "" {
-			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+
+		if companyProduct != nil {
+			if companyProduct.Scale != "" {
+				conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+			}
 		}
 
 		condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
@@ -2451,13 +2460,16 @@ func (this *ActivityCoAntroller) LabelMoreList() {
 	}
 	//判断客户规模是否属于可见范围的活动
 	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-	if err != nil {
+	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 		return
 	}
-	if companyProduct.Scale != "" {
-		conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+
+	if companyProduct != nil {
+		if companyProduct.Scale != "" {
+			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		}
 	}
 	condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 
@@ -2652,13 +2664,15 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	}
 	//判断客户规模是否属于可见范围的活动
 	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-	if err != nil {
+	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 		return
 	}
-	if companyProduct.Scale != "" {
-		conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+	if companyProduct != nil {
+		if companyProduct.Scale != "" {
+			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		}
 	}
 
 	condition += ` AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
@@ -2896,13 +2910,15 @@ func (this *ActivityCoAntroller) LabelTypeListPc() {
 		}
 		//判断客户规模是否属于可见范围的活动
 		companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 			return
 		}
-		if companyProduct.Scale != "" {
-			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		if companyProduct != nil {
+			if companyProduct.Scale != "" {
+				conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+			}
 		}
 		condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 		sortTime = ` mintimesort ASC `

+ 1 - 1
controllers/article.go

@@ -882,7 +882,7 @@ func (this *ArticleController) Pdfwatermark() {
 	//缓存校验
 	cacheKey := fmt.Sprint("xygx:apply_record:add:", uid, "ArticleId_", articleId)
 	ttlTime := utils.Rc.GetRedisTTL(cacheKey)
-	if ttlTime > 0 {
+	if ttlTime > 0 && user.CompanyId != 16 {
 		br.Msg = "下载失败,下载过于频繁"
 		br.ErrMsg = "下载失败,下载过于频繁:mobile" + user.Mobile
 		return

+ 1 - 0
models/article.go

@@ -507,6 +507,7 @@ type ArticleResultApi struct {
 type ArticleResultApidate struct {
 	ArticleId     int                      `json:"id"`
 	Title         string                   `json:"title"`
+	File          string                   `json:"file"`
 	TitleEn       string                   `json:"title_en"`
 	Frequency     string                   `json:"frequency"`
 	CreateDate    string                   `json:"create_date"`

+ 1 - 0
models/tactics.go

@@ -79,6 +79,7 @@ type Tactics2 struct {
 	ReportType      int       `description:"报告类型,1行业报告,2产业报告,0无"`
 	Stock           string    `description:"个股标签"`
 	FieldName       string    `description:"产业标签"`
+	File            string    `description:"Pdf下载链接"`
 }
 
 func GetTacticsList2(endDate string) (list []*Tactics2, err error) {

+ 4 - 3
services/article.go

@@ -365,6 +365,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			item.ArticleId = v.ArticleId
 			item.Title = v.Title
 			item.TitleEn = v.TitleEn
+			item.File = v.File
 			if v.Frequency == "日度" {
 				item.UpdateFrequency = "daily"
 			} else if v.Frequency == "周度" {
@@ -473,7 +474,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			return err
 		}
 		v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
-		expertNumStr, expertContentStr, interviewDateStr, fileLink, bodyReturn := BodyAnalysis2(v.Body)
+		expertNumStr, expertContentStr, interviewDateStr, _, bodyReturn := BodyAnalysis2(v.Body)
 		if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
 			v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
 			v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
@@ -535,7 +536,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			//updateParams["IsClass"] = v.IsClass
 			v.Department = "弘则权益研究"
 			updateParams["Department"] = v.Department
-			updateParams["FileLink"] = fileLink
+			updateParams["FileLink"] = v.File
 			updateParams["Stock"] = v.Stock
 			updateParams["FieldName"] = v.FieldName
 			whereParam := map[string]interface{}{"article_id": v.ArticleId}
@@ -572,7 +573,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 			item.IsSummary = v.IsSummary
 			item.IsReport = v.IsReport
 			item.ReportType = v.ReportType
-			item.FileLink = fileLink
+			item.FileLink = v.File
 			item.MatchTypeName = matchTypeName
 			item.Stock = v.Stock
 			item.FieldName = v.FieldName