feat(report):完成电费公示报表的计算功能。

This commit is contained in:
徐涛
2022-08-24 15:20:03 +08:00
parent 4919c7152f
commit 4aa7221158
5 changed files with 268 additions and 4 deletions

View File

@@ -37,6 +37,7 @@ func InitializeReportController(router *gin.Engine) {
router.POST("/report/:rid/publish", security.EnterpriseAuthorize, publishReport)
router.GET("/reports", security.MustAuthenticated, searchReports)
router.GET("/report/:rid", security.MustAuthenticated, fetchReportPublicity)
router.POST("/report/:rid/calculate", security.EnterpriseAuthorize, calculateReport)
}
func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportId string) bool {
@@ -461,3 +462,17 @@ func fetchReportPublicity(c *gin.Context) {
}
result.Success("已经取得指定公示报表的发布版本。", tools.ConvertStructToMap(publicity))
}
func calculateReport(c *gin.Context) {
result := response.NewResult(c)
requestReportId := c.Param("rid")
if !ensureReportBelongs(c, result, requestReportId) {
return
}
err := service.CalculateService.ComprehensivelyCalculateReport(requestReportId)
if err != nil {
result.Error(http.StatusInternalServerError, err.Error())
return
}
result.Success("指定公示报表中的数据已经计算完毕。")
}