diff --git a/controller/report.go b/controller/report.go index 25ab6ca..156382e 100644 --- a/controller/report.go +++ b/controller/report.go @@ -14,6 +14,7 @@ func InitializeReportController(router *gin.Engine) { router.GET("/reports/with/drafts", security.EnterpriseAuthorize, fetchNewestReportOfParkWithDraft) router.POST("/park/:pid/report", security.EnterpriseAuthorize, initializeNewReport) router.GET("/report/:rid/step/state", security.EnterpriseAuthorize, fetchReportStepStates) + router.GET("/report/:rid/summary", security.EnterpriseAuthorize, fetchReportParkSummary) } func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportId string) bool { @@ -92,3 +93,17 @@ func fetchReportStepStates(c *gin.Context) { } result.Json(http.StatusOK, "已经获取到指定报表的填写状态。", gin.H{"steps": requestReport.StepState}) } + +func fetchReportParkSummary(c *gin.Context) { + result := response.NewResult(c) + requestReportId := c.Param("rid") + if !ensureReportBelongs(c, result, requestReportId) { + return + } + summary, err := service.ReportService.RetreiveParkSummary(requestReportId) + if err != nil { + result.NotFound(err.Error()) + return + } + result.Json(http.StatusOK, "已经获取到指定报表中的园区概况。", gin.H{"summary": summary}) +} diff --git a/model/report_summary.go b/model/report_summary.go index bf607ea..42013e3 100644 --- a/model/report_summary.go +++ b/model/report_summary.go @@ -7,12 +7,12 @@ type ReportSummary struct { Overall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overall"` OverallFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overallFee"` OverallPrice decimal.Decimal `xorm:"numeric(16,8)" json:"overallPrice"` - Critical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"critial"` + Critical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"critical"` CriticalFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"criticalFee"` CriticalPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"criticalPrice"` - Peek decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peek"` - PeekFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peekFee"` - PeekPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"peekPrice"` + Peek decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peak"` + PeekFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peakFee"` + PeekPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"peakPrice"` Flat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"flat"` FlatFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"flatFee"` FlatPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"flatPrice"` diff --git a/service/report.go b/service/report.go index 1dc0ef9..24ec796 100644 --- a/service/report.go +++ b/service/report.go @@ -142,3 +142,12 @@ func (_ReportService) RetreiveReportIndex(rid string) (*model.Report, error) { return nil, err } } + +func (_ReportService) RetreiveParkSummary(rid string) (*model.ReportSummary, error) { + var summary = new(model.ReportSummary) + _, err := global.DBConn.ID(rid).Get(summary) + if err != nil { + return nil, err + } + return summary, nil +}