Browse Source

研选分享权限处理

xingzai 3 years ago
parent
commit
afd0ddb800
5 changed files with 53 additions and 16 deletions
  1. 14 5
      controllers/article.go
  2. 33 8
      controllers/report.go
  3. 1 0
      models/article.go
  4. 4 3
      models/article_department.go
  5. 1 0
      models/report.go

+ 14 - 5
controllers/article.go

@@ -112,6 +112,18 @@ func (this *ArticleController) Detail() {
 					hasPersion = true
 				}
 			}
+			if strings.Contains(detail.CategoryName, "研选") {
+				detail.IsResearch = true
+			}
+			userType, _, err := services.GetUserType(user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+				return
+			}
+			if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
+				hasPersion = false
+			}
 			if hasPersion {
 				hasPermission = 1
 				historyRecord := new(models.CygxArticleHistoryRecord)
@@ -157,9 +169,7 @@ func (this *ArticleController) Detail() {
 				}
 			}
 		}
-		if strings.Contains(detail.CategoryName, "研选") {
-			detail.IsResearch = true
-		}
+
 		collectCount, err := models.GetArticleCollectCount(uid, articleId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
@@ -249,9 +259,8 @@ Loop:
 		if detail.IsReport == 1 {
 			detail.IsBelongReport = true
 		}
+		detail.HaveResearch = true
 	}
-
-	fmt.Println(uid)
 	resp := new(models.ArticleDetailResp)
 	resp.HasPermission = hasPermission
 	resp.HasFree = hasFree

+ 33 - 8
controllers/report.go

@@ -633,16 +633,12 @@ func (this *ReportController) IndustryListByDepartment() {
 		return
 	}
 	uid := user.UserId
-
-	fmt.Println(uid)
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	chartPermissionId, _ := this.GetInt("ChartPermissionId")
 	var startSize int
 	var condition string
-
 	condition = ` AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
-
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
 	}
@@ -652,6 +648,22 @@ func (this *ReportController) IndustryListByDepartment() {
 	startSize = paging.StartIndex(currentIndex, pageSize)
 	total, err := models.GetArticleDepartmentCount(condition)
 	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.CygxArticleDepartmentList)
+	userType, _, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 {
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	resp.HaveResearch = true
 	//获取作者信息,并排序
 	list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
 	if err != nil {
@@ -690,7 +702,7 @@ func (this *ReportController) IndustryListByDepartment() {
 			list[k].IsMyFollow = true
 		}
 	}
-	resp := new(models.CygxArticleDepartmentList)
+
 	resp.ListnNew, err = models.GetIndustrialSubjectByDepartmentNew(chartPermissionId)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -840,15 +852,28 @@ func (this *ReportController) ReportList() {
 	var total int
 	resp := new(models.ReportArticleWhichIndustrialRepList)
 	page := paging.GetPaging(currentIndex, pageSize, total)
-
+	userType, _, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 {
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	resp.HaveResearch = true
 	if departmentId > 0 {
 		condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
 	}
-
 	if industrialManagementId > 0 {
 		condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
 	}
-	total, err := models.GetWhichDepartmentCount(condition)
+	total, err = models.GetWhichDepartmentCount(condition)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()

+ 1 - 0
models/article.go

@@ -84,6 +84,7 @@ type HomeArticle struct {
 }
 
 type ArticleDetail struct {
+	HaveResearch         bool   `description:"是否有研选权限"`
 	ArticleId            int    `description:"报告id"`
 	Title                string `description:"标题"`
 	TitleEn              string `description:"英文标题 "`

+ 4 - 3
models/article_department.go

@@ -30,9 +30,10 @@ type CygxArticleDepartmentId struct {
 }
 
 type CygxArticleDepartmentList struct {
-	Paging   *paging.PagingItem `description:"分页数据"`
-	ListnNew []*IndustrialManagementIdInt
-	List     []*CygxArticleDepartmentRep
+	HaveResearch bool               `description:"是否有研选权限"`
+	Paging       *paging.PagingItem `description:"分页数据"`
+	ListnNew     []*IndustrialManagementIdInt
+	List         []*CygxArticleDepartmentRep
 }
 
 //详情

+ 1 - 0
models/report.go

@@ -150,6 +150,7 @@ type ReportArticleWhichIndustrial struct {
 }
 
 type ReportArticleWhichIndustrialRepList struct {
+	HaveResearch bool               `description:"是否有研选权限"`
 	Paging       *paging.PagingItem `description:"分页数据"`
 	NickName     string             `description:"作者昵称"`
 	IndustryName string             `description:"产业名称"`