forked from free-lancers/electricity_bill_calc_service
		
	feat(report):完成获取报表中园区概况接口。
This commit is contained in:
		| @@ -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}) | ||||
| } | ||||
|   | ||||
| @@ -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"` | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user