Browse Source

查询章节列表权限

xyxie 11 months ago
parent
commit
6b2393acde
2 changed files with 22 additions and 0 deletions
  1. 14 0
      controllers/report_chapter_type.go
  2. 8 0
      models/report_chapter_type_permission.go

+ 14 - 0
controllers/report_chapter_type.go

@@ -48,8 +48,20 @@ func (this *ReportChapterTypeController) List() {
 		br.ErrMsg = "获取报告章节列表失败, Err: " + e.Error()
 		return
 	}
+	mappingList, e := models.GetChapterTypePermissionByResearchType(reportType)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取章节类型权限列表失败, Err: " + e.Error()
+		return
+	}
+	mappingMap := make(map[int][]int)
+	for _, v := range mappingList {
+		mappingMap[v.ReportChapterTypeId] = append(mappingMap[v.ReportChapterTypeId], v.ChartPermissionId)
+	}
+
 	respList := make([]*models.ReportChapterTypeListItem, 0)
 	for i := range list {
+		permissionIds, _ := mappingMap[list[i].ReportChapterTypeId]
 		respList = append(respList, &models.ReportChapterTypeListItem{
 			ReportChapterTypeId:   list[i].ReportChapterTypeId,
 			ReportChapterTypeName: list[i].ReportChapterTypeName,
@@ -61,6 +73,8 @@ func (this *ReportChapterTypeController) List() {
 			WordsImage:            list[i].YbBottomIcon, // 此处的不一样
 			EditImgUrl:            list[i].EditImgUrl,
 			IsShow:                list[i].IsShow,
+			Enabled:               list[i].Enabled,
+			ChartPermissionIdList: permissionIds,
 		})
 	}
 

+ 8 - 0
models/report_chapter_type_permission.go

@@ -73,3 +73,11 @@ func SetReportChapterTypePermission(chapterTypeId int, researchType string, newP
 	}
 	return
 }
+
+// GetChapterTypePermissionByResearchType 根据章节类型ID及研报类型获取章节类型权限列表
+func GetChapterTypePermissionByResearchType(researchType string) (list []*ReportChapterTypePermission, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` SELECT * FROM report_chapter_type_permission WHERE research_type = ? ORDER BY chart_permission_id ASC `
+	_, err = o.Raw(sql, researchType).QueryRows(&list)
+	return
+}