feat(report):完成获取公示用数据接口的功能。

This commit is contained in:
徐涛
2022-08-24 11:26:17 +08:00
parent ad19169ac5
commit 4919c7152f
4 changed files with 289 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ func InitializeReportController(router *gin.Engine) {
router.PUT("/report/:rid/step/meter/register", security.EnterpriseAuthorize, progressEndUserRegister)
router.POST("/report/:rid/publish", security.EnterpriseAuthorize, publishReport)
router.GET("/reports", security.MustAuthenticated, searchReports)
router.GET("/report/:rid", security.MustAuthenticated, fetchReportPublicity)
}
func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportId string) bool {
@@ -444,3 +445,19 @@ func searchReports(c *gin.Context) {
gin.H{"reports": records},
)
}
func fetchReportPublicity(c *gin.Context) {
result := response.NewResult(c)
requestReportId := c.Param("rid")
publicity, err := service.ReportService.AssembleReportPublicity(requestReportId)
if err != nil {
if nfErr, ok := err.(exceptions.NotFoundError); ok {
result.NotFound(nfErr.Error())
return
} else {
result.Error(http.StatusInternalServerError, err.Error())
return
}
}
result.Success("已经取得指定公示报表的发布版本。", tools.ConvertStructToMap(publicity))
}