enhance(enduser):为导出的用户抄表记录文件增加文件名内容。
This commit is contained in:
parent
dce83d7e49
commit
e619d27559
|
@ -6,6 +6,7 @@ import (
|
||||||
"electricity_bill_calc/response"
|
"electricity_bill_calc/response"
|
||||||
"electricity_bill_calc/security"
|
"electricity_bill_calc/security"
|
||||||
"electricity_bill_calc/service"
|
"electricity_bill_calc/service"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -54,6 +55,16 @@ func downloadEndUserRegisterTemplate(c *gin.Context) {
|
||||||
result.NotFound(err.Error())
|
result.NotFound(err.Error())
|
||||||
return
|
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)
|
meterType, err := service.ReportService.RetreiveParkEndUserMeterType(requestReportId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Error(http.StatusInternalServerError, err.Error())
|
result.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
@ -68,7 +79,7 @@ func downloadEndUserRegisterTemplate(c *gin.Context) {
|
||||||
c.Status(http.StatusOK)
|
c.Status(http.StatusOK)
|
||||||
c.Header("Content-Type", "application/octet-stream")
|
c.Header("Content-Type", "application/octet-stream")
|
||||||
c.Header("Content-Transfer-Encoding", "binary")
|
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](
|
gen := lo.Ternary[excel.ExcelTemplateGenerator](
|
||||||
meterType == 0,
|
meterType == 0,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user