From b62a3e717b74557d9c43f4c62e5f5b2319542898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sat, 20 Aug 2022 16:49:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(report):=E5=AE=8C=E6=88=90=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8A=A5=E8=A1=A8=E4=B8=AD=E5=9B=AD=E5=8C=BA=E6=A6=82?= =?UTF-8?q?=E5=86=B5=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/report.go | 15 +++++++++++++++ model/report_summary.go | 8 ++++---- service/report.go | 9 +++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) 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 +}