forked from free-lancers/electricity_bill_calc_service
feat(report):完成获取公示用数据接口的功能。
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user