|
@@ -12,6 +12,7 @@ import (
|
|
|
"hongze/hongze_yb/models/tables/rddp/report"
|
|
|
"hongze/hongze_yb/models/tables/rddp/report_chapter"
|
|
|
"hongze/hongze_yb/models/tables/rddp/smart_report_resource"
|
|
|
+ "hongze/hongze_yb/models/tables/report_chapter_permission_mapping"
|
|
|
"hongze/hongze_yb/models/tables/report_chapter_type"
|
|
|
"hongze/hongze_yb/models/tables/user_report_chapter_set"
|
|
|
"hongze/hongze_yb/services"
|
|
@@ -191,7 +192,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
|
|
|
err = errors.New("无有效的章节类型")
|
|
|
return
|
|
|
}
|
|
|
- reportChapter, err := report_chapter.GetContentById(reportChapterId, typeIds)
|
|
|
+ reportChapter, err := report_chapter.GetItemById(reportChapterId)
|
|
|
if err != nil {
|
|
|
errMsg = err.Error()
|
|
|
err = errors.New("章节查询出错")
|
|
@@ -213,12 +214,13 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
|
|
|
err = errors.New("报告不存在")
|
|
|
return
|
|
|
}
|
|
|
- if reportInfo.ClassifyNameFirst == "周报" && reportChapter.IsEdit != 1 {
|
|
|
- err = errors.New("章节未编辑")
|
|
|
- return
|
|
|
- }
|
|
|
+ //if reportInfo.ClassifyNameFirst == "周报" && reportChapter.IsEdit != 1 {
|
|
|
+ // err = errors.New("章节未编辑")
|
|
|
+ // return
|
|
|
+ //}
|
|
|
//判断权限
|
|
|
var newTypeIds []int
|
|
|
+ var reportChapterIdList []int
|
|
|
if reportInfo.ClassifyNameFirst == "晨报" {
|
|
|
authOk, permissionCheckInfo, err = CheckDayReportPermission(user, productAuthOk)
|
|
|
if err != nil && err != utils.ErrNoRow {
|
|
@@ -226,15 +228,15 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
|
|
|
err = errors.New("权限查询出错")
|
|
|
return
|
|
|
}
|
|
|
- } else if reportInfo.ClassifyNameFirst == "周报" {
|
|
|
- authOk, permissionCheckInfo, newTypeIds, err = CheckWeekReportPermission(user, productAuthOk)
|
|
|
+ } else {
|
|
|
+ authOk, permissionCheckInfo, newTypeIds, reportChapterIdList, err = CheckWeekReportPermission(user, reportInfo.Id, productAuthOk)
|
|
|
if err != nil && err != utils.ErrNoRow {
|
|
|
errMsg = err.Error()
|
|
|
err = errors.New("权限查询出错")
|
|
|
return
|
|
|
}
|
|
|
- for _, v := range newTypeIds {
|
|
|
- if v == reportChapter.TypeId {
|
|
|
+ for _, v := range reportChapterIdList {
|
|
|
+ if v == reportChapter.ReportChapterId {
|
|
|
chapterAuthOk = true
|
|
|
}
|
|
|
}
|
|
@@ -385,8 +387,19 @@ func GetMenuChapter(reportId int, typeIds []int, classifyNameFirst string, repor
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// CheckWeekReportPermission 验证周报的权限
|
|
|
-func CheckWeekReportPermission(userInfo user.UserInfo, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, validTypeIds []int, err error) {
|
|
|
+// CheckWeekReportPermission
|
|
|
+// @Description: 验证周报的权限(并获取拥有权限的章节id列表)
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-06-24 11:06:52
|
|
|
+// @param userInfo user.UserInfo
|
|
|
+// @param reportId int
|
|
|
+// @param productAuthOk bool
|
|
|
+// @return authOk bool
|
|
|
+// @return permissionCheckInfo response.PermissionCheckInfo
|
|
|
+// @return validTypeIds []int 分类关联的章节类型ID列表
|
|
|
+// @return reportChapterIdList []int 并获取拥有权限的章节id列表
|
|
|
+// @return err error
|
|
|
+func CheckWeekReportPermission(userInfo user.UserInfo, reportId int, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, validTypeIds, reportChapterIdList []int, err error) {
|
|
|
var permissionIds []int
|
|
|
var validPermissionIds []int //最后允许显示的章节
|
|
|
if productAuthOk {
|
|
@@ -402,7 +415,13 @@ func CheckWeekReportPermission(userInfo user.UserInfo, productAuthOk bool) (auth
|
|
|
//返回可用的章节列表
|
|
|
if len(validPermissionIds) > 0 {
|
|
|
validTypeIds, err = chart_permission_chapter_mapping.GetReportIdsByPermisssionIds(validPermissionIds, "week")
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ reportChapterIdList, err = report_chapter_permission_mapping.GetReportChapterListByPermissionIdsAndReportId(validPermissionIds, reportId)
|
|
|
}
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -515,3 +534,91 @@ func GetReportChapterVideoList(permissionIds []int, classifyName string, list []
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// GetChapterListByReportChapterIdList
|
|
|
+// @Description: 根据报告获取章节列表
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-06-24 11:23:36
|
|
|
+// @param classifyNameFirst string
|
|
|
+// @param reportId int
|
|
|
+// @param reportChapterIdList []int
|
|
|
+// @param reportCreateTime time.Time
|
|
|
+// @return reportTypeList response.ReportChapterList
|
|
|
+// @return err error
|
|
|
+func GetChapterListByReportChapterIdList(classifyNameFirst string, reportId int, reportChapterIdList []int) (reportTypeList response.ReportChapterList, err error) {
|
|
|
+ var errMsg string
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ global.LOG.Critical(fmt.Sprintf("GetChapterListByReport: err:%s, errMsg:%s", err.Error(), errMsg))
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ //查询有效的章节
|
|
|
+ typeList, tErr := report_chapter_type.GetEffectTypes()
|
|
|
+ if tErr != nil {
|
|
|
+ errMsg = tErr.Error()
|
|
|
+ err = errors.New("章节类型查询出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(typeList) == 0 {
|
|
|
+ err = errors.New("无有效的章节")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ typeMap := make(map[uint64]*report_chapter_type.ReportChapterType)
|
|
|
+ for _, v := range typeList {
|
|
|
+ typeMap[v.ReportChapterTypeId] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ var chapterList []*report_chapter.ReportChapter
|
|
|
+ if len(reportChapterIdList) > 0 {
|
|
|
+ //获取所有当前研报有权限的章节
|
|
|
+ chapterList, tErr = report_chapter.GetListByChapterIds(reportChapterIdList)
|
|
|
+ } else {
|
|
|
+ // 获取所有报告章节
|
|
|
+ chapterList, tErr = report_chapter.GetListByReportId(reportId, classifyNameFirst)
|
|
|
+ }
|
|
|
+ if tErr != nil && tErr != utils.ErrNoRow {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("章节查询出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(chapterList) == 0 {
|
|
|
+ err = errors.New("无有效章节")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, item := range chapterList {
|
|
|
+ typeItem, ok1 := typeMap[uint64(item.TypeId)]
|
|
|
+ // 如果是配置的章节,那么就需要判断是否禁用,如果禁用,则不展示
|
|
|
+ if item.TypeId > 0 && !ok1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ temp := new(response.ReportChapterListItem)
|
|
|
+ temp.ReportChapterId = item.ReportChapterId
|
|
|
+ temp.TypeId = item.TypeId
|
|
|
+ temp.TypeName = item.TypeName
|
|
|
+ temp.Title = item.Title
|
|
|
+ temp.Trend = item.Trend
|
|
|
+ temp.ReportId = item.ReportId
|
|
|
+ temp.Sort = item.Sort
|
|
|
+ temp.PublishTime = item.PublishTime
|
|
|
+ temp.VideoUrl = item.VideoUrl
|
|
|
+ temp.VideoName = item.VideoName
|
|
|
+ temp.VideoPlaySeconds = item.VideoPlaySeconds
|
|
|
+ temp.VideoSize = item.VideoSize
|
|
|
+
|
|
|
+ // 系统配置的参数,只有配置的章节类型,才能赋值
|
|
|
+ if typeItem != nil {
|
|
|
+ temp.ReportChapterTypeKey = typeItem.ReportChapterTypeKey
|
|
|
+ temp.ReportChapterTypeName = typeItem.ReportChapterTypeName
|
|
|
+ temp.ReportChapterTypeThumb = typeItem.YbIconUrl
|
|
|
+ }
|
|
|
+
|
|
|
+ reportTypeList = append(reportTypeList, temp)
|
|
|
+ }
|
|
|
+ if len(reportTypeList) > 0 {
|
|
|
+ sort.Sort(reportTypeList)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|