|
@@ -3,9 +3,18 @@ package report
|
|
import (
|
|
import (
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
"hongze/hongze_yb/models/tables/research_report"
|
|
"hongze/hongze_yb/models/tables/research_report"
|
|
|
|
+ "hongze/hongze_yb/models/tables/research_report_type"
|
|
"hongze/hongze_yb/utils"
|
|
"hongze/hongze_yb/utils"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+type ResearchReportInfo struct {
|
|
|
|
+ ResearchReportInfo *research_report.ResearchReport `json:"research_report_info"`
|
|
|
|
+ ResearchReportTypeList []*company_report_permission.ResearchReportTypeList `json:"research_report_type_list"`
|
|
|
|
+ HasMenu int `json:"has_menu"`
|
|
|
|
+ ResearchReportTypeContentList []*research_report.ResearchReportTypeContent `description:"报告详情"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetResearchReportInfo 获取报告详情
|
|
func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchReportInfo, hasPermission bool, err error) {
|
|
func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchReportInfo, hasPermission bool, err error) {
|
|
//获取报告详情
|
|
//获取报告详情
|
|
reportInfo, err := research_report.GetByResearchReportId(researchReportId)
|
|
reportInfo, err := research_report.GetByResearchReportId(researchReportId)
|
|
@@ -61,7 +70,7 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
|
|
} else if len(researchReportTypeList) == 1 {
|
|
} else if len(researchReportTypeList) == 1 {
|
|
//只有一个章节,即没有目录的时候,需要直接返回章节详情
|
|
//只有一个章节,即没有目录的时候,需要直接返回章节详情
|
|
result.HasMenu = 0
|
|
result.HasMenu = 0
|
|
- researchReportTypeContent, tmpErr := research_report.GetResearchReportTypeContent(researchReportTypeList[0].ResearchReportTypeId)
|
|
|
|
|
|
+ researchReportTypeContent, tmpErr := research_report.GetResearchReportTypeContentList(researchReportTypeList[0].ResearchReportTypeId)
|
|
if tmpErr != nil {
|
|
if tmpErr != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -70,9 +79,73 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-type ResearchReportInfo struct {
|
|
|
|
- ResearchReportInfo *research_report.ResearchReport `json:"research_report_info"`
|
|
|
|
- ResearchReportTypeList []*company_report_permission.ResearchReportTypeList `json:"research_report_type_list"`
|
|
|
|
- HasMenu int `json:"has_menu"`
|
|
|
|
- ResearchReportTypeContentList []*research_report.ResearchReportTypeContent `description:"报告详情"`
|
|
|
|
|
|
+type ResearchReportTypeContentInfo struct {
|
|
|
|
+ ResearchReportTypeInfo *research_report_type.ResearchReportTypeInfo `json:"research_report_type_info"`
|
|
|
|
+ Add int `json:"add"`
|
|
|
|
+ ResearchReportTypeContentList []*research_report.ResearchReportTypeContent `description:"报告详情" json:"research_report_type_content_list"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetResearchReportTypeContentInfo 获取报告章节详情
|
|
|
|
+func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (result ResearchReportTypeContentInfo, hasPermission bool, err error) {
|
|
|
|
+ //获取章节详情
|
|
|
|
+ researchReportTypeContentList, err := research_report.GetResearchReportTypeContentList(researchReportTypeId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ researchReportTypeInfo, err := research_report_type.GetResearchReportTypeInfo(researchReportTypeId)
|
|
|
|
+ //获取报告详情
|
|
|
|
+ reportInfo, err := research_report.GetByResearchReportId(researchReportTypeInfo.ResearchReportID)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ reportType := reportInfo.Type
|
|
|
|
+
|
|
|
|
+ //这些个报告需要做权限校验
|
|
|
|
+ if utils.InArray(reportInfo.Type, []string{"week", "month", "two_week", "other"}) {
|
|
|
|
+ list, tmpErr := company_report_permission.GetReportVarietyList(userId, reportType)
|
|
|
|
+ if tmpErr != nil {
|
|
|
|
+ err = tmpErr
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if reportInfo.Type == "week" {
|
|
|
|
+ //周报校验章节是否在权限内
|
|
|
|
+ for _, v := range list {
|
|
|
|
+ if researchReportTypeInfo.ReportChapterTypeId == v.ReportChapterTypeId {
|
|
|
|
+ hasPermission = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //双周报和月报校验 类型是否在权限内
|
|
|
|
+ for _, v := range list {
|
|
|
|
+ if reportInfo.ResearchReportID == v.ReportChapterTypeId {
|
|
|
|
+ hasPermission = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !hasPermission {
|
|
|
|
+ //permissionName, tmpErr := company_report_permission.GetPermissionNameByReportId(reportInfo.ResearchReportID, reportType)
|
|
|
|
+ //if tmpErr != nil {
|
|
|
|
+ // err = tmpErr
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ hasPermission = true
|
|
|
|
+ }
|
|
|
|
+ add := 1
|
|
|
|
+ if len(researchReportTypeContentList) > 0 {
|
|
|
|
+ add = 0
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result = ResearchReportTypeContentInfo{
|
|
|
|
+ ResearchReportTypeContentList: researchReportTypeContentList,
|
|
|
|
+ ResearchReportTypeInfo: researchReportTypeInfo,
|
|
|
|
+ Add: add,
|
|
|
|
+ }
|
|
|
|
+ return
|
|
}
|
|
}
|