package report import ( "github.com/gin-gonic/gin" "hongze/hongze_yb/controller/response" "hongze/hongze_yb/logic/report" "hongze/hongze_yb/services/user" "strconv" ) // GetResearchReportInfo // @Tags 报告接口 // @Summary 获取报告详情 // @Description 获取报告详情 // @Security ApiKeyAuth // @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273" // @Accept json // @Product json // @Param research_report_id query int true "活动ID" // @Success 200 {object} yb_activity.ActivityDetail // @failure 400 {string} string "获取失败" // @Router /report/research_report [get] func GetResearchReportInfo(c *gin.Context) { userInfo := user.GetInfoByClaims(c) researchReportIdStr := c.DefaultQuery("research_report_id", "") if researchReportIdStr == "" { response.Fail("请传入报告id", c) return } researchReportId, tmpErr := strconv.Atoi(researchReportIdStr) if tmpErr != nil { response.Fail("报告id异常", c) return } reportInfo, hasPermission, err := report.GetResearchReportInfo(uint64(researchReportId), userInfo.UserID) if err != nil { response.Fail("获取报告失败", c) return } if !hasPermission { response.Fail("无权限", c) return } response.OkData("获取成功", reportInfo, c) } // GetResearchReportChapter // @Tags 报告接口 // @Summary 获取报告章节详情 // @Description 获取报告章节详情 // @Security ApiKeyAuth // @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273" // @Accept json // @Product json // @Param research_report_type_id query int true "章节ID" // @Success 200 {object} yb_activity.ActivityDetail // @failure 400 {string} string "获取失败" // @Router /report/research_report_chapter [get] func GetResearchReportChapter(c *gin.Context) { userInfo := user.GetInfoByClaims(c) researchReportTypeIdStr := c.DefaultQuery("research_report_type_id", "") if researchReportTypeIdStr == "" { response.Fail("请传入报告章节id", c) return } researchReportId, tmpErr := strconv.Atoi(researchReportTypeIdStr) if tmpErr != nil { response.Fail("报告章节id异常", c) return } reportInfo, hasPermission, err := report.GetResearchReportTypeContentInfo(uint64(researchReportId), userInfo.UserID) if err != nil { response.Fail("获取报告章节失败", c) return } if !hasPermission { response.Fail("无权限", c) return } response.OkData("获取成功", reportInfo, c) }