forked from free-lancers/electricity_bill_calc_service
		
	enhance(enduser):为导出的用户抄表记录文件增加文件名内容。
This commit is contained in:
		| @@ -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, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user