research_report.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package report
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "hongze/hongze_yb/controller/response"
  5. "hongze/hongze_yb/logic/report"
  6. "hongze/hongze_yb/services/user"
  7. "strconv"
  8. )
  9. // GetResearchReportInfo
  10. // @Tags 报告接口
  11. // @Summary 获取报告详情
  12. // @Description 获取报告详情
  13. // @Security ApiKeyAuth
  14. // @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
  15. // @Accept json
  16. // @Product json
  17. // @Param research_report_id query int true "活动ID"
  18. // @Success 200 {object} yb_activity.ActivityDetail
  19. // @failure 400 {string} string "获取失败"
  20. // @Router /report/research_report [get]
  21. func GetResearchReportInfo(c *gin.Context) {
  22. userInfo := user.GetInfoByClaims(c)
  23. researchReportIdStr := c.DefaultQuery("research_report_id", "")
  24. if researchReportIdStr == "" {
  25. response.Fail("请传入报告id", c)
  26. return
  27. }
  28. researchReportId, tmpErr := strconv.Atoi(researchReportIdStr)
  29. if tmpErr != nil {
  30. response.Fail("报告id异常", c)
  31. return
  32. }
  33. reportInfo, hasPermission, err := report.GetResearchReportInfo(uint64(researchReportId), userInfo.UserID)
  34. if err != nil {
  35. response.Fail("获取报告失败", c)
  36. return
  37. }
  38. if !hasPermission {
  39. response.Fail("无权限", c)
  40. return
  41. }
  42. response.OkData("获取成功", reportInfo, c)
  43. }