From e619d27559fb9372875e77ccc14569ba2c75f841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Thu, 8 Sep 2022 20:34:01 +0800 Subject: [PATCH] =?UTF-8?q?enhance(enduser):=E4=B8=BA=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=88=B7=E6=8A=84=E8=A1=A8=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/end_user.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/controller/end_user.go b/controller/end_user.go index 01f148b..42ff28c 100644 --- a/controller/end_user.go +++ b/controller/end_user.go @@ -6,6 +6,7 @@ import ( "electricity_bill_calc/response" "electricity_bill_calc/security" "electricity_bill_calc/service" + "fmt" "net/http" "strconv" @@ -54,6 +55,16 @@ func downloadEndUserRegisterTemplate(c *gin.Context) { result.NotFound(err.Error()) return } + reportIndex, err := service.ReportService.RetreiveReportIndex(requestReportId) + if err != nil { + result.NotFound(err.Error()) + return + } + park, err := service.ParkService.FetchParkDetail(reportIndex.ParkId) + if err != nil { + result.NotFound(err.Error()) + return + } meterType, err := service.ReportService.RetreiveParkEndUserMeterType(requestReportId) if err != nil { result.Error(http.StatusInternalServerError, err.Error()) @@ -68,7 +79,7 @@ func downloadEndUserRegisterTemplate(c *gin.Context) { c.Status(http.StatusOK) c.Header("Content-Type", "application/octet-stream") c.Header("Content-Transfer-Encoding", "binary") - c.Header("Content-Disposition", "attachment; filename=抄表记录.xlsx") + c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=抄表记录-%s-%s.xlsx", park.Name, reportIndex.Period.Format("2006-01"))) gen := lo.Ternary[excel.ExcelTemplateGenerator]( meterType == 0,