Browse Source

手动添加纪要库之后,小程序权限校验修改

xingzai 3 years ago
parent
commit
96e264ba51
2 changed files with 27 additions and 13 deletions
  1. 18 11
      controllers/article.go
  2. 9 2
      services/tactics.go

+ 18 - 11
controllers/article.go

@@ -114,18 +114,25 @@ func (this *ArticleController) Detail() {
 			//		hasPermission = 3
 			//	}
 			//}
-			articlePermission, err := models.GetArticlePermission(detail.CategoryId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-				return
-			}
-			if articlePermission == nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-				return
+			var articlePermissionPermissionName string
+			if detail.CategoryId > 0 {
+				articlePermission, err := models.GetArticlePermission(detail.CategoryId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+					return
+				}
+				if articlePermission == nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+					return
+				}
+				articlePermissionPermissionName = articlePermission.PermissionName
+			} else {
+				articlePermissionPermissionName = detail.CategoryName
 			}
-			if strings.Contains(companyPermission, articlePermission.PermissionName) {
+
+			if strings.Contains(companyPermission, articlePermissionPermissionName) {
 				hasPermission = 1
 				historyRecord := new(models.CygxArticleHistoryRecord)
 				historyRecord.UserId = uid

+ 9 - 2
services/tactics.go

@@ -398,7 +398,12 @@ func SyncTacticsListAddreport() (err error) {
 		// 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
 		if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
 			if v.UpdateFrequency == "daily" {
-				titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + strconv.Itoa(v.PublishDate.Day()) + ")"
+				var daystr string
+				daystr = strconv.Itoa(v.PublishDate.Day())
+				if len(daystr) == 1 {
+					daystr = "0" + daystr
+				}
+				titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
 			} else if v.UpdateFrequency == "weekly" {
 				titleNew = v.Title + utils.WeekByDate(v.PublishDate)
 			}
@@ -682,7 +687,9 @@ func BodyAnalysis2(body string) (expertNumStr, expertContentStr, interviewDateSt
 				numEnd := strings.Index(v, ".pdf")
 				fileLink = v[numStar : numEnd+4]
 			}
-			body = strings.Replace(body, v, "", -1)
+			if strings.Index(v, ".pdf") > 0 {
+				body = strings.Replace(body, v, "", -1)
+			}
 		}
 		if !strings.HasPrefix(fileLink, "https") && len(fileLink) > 0 {
 			fileLink = "https" + fileLink[4:len(fileLink)]