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,