feat: export excel file

This commit is contained in:
zchengo
2022-12-27 19:18:58 +08:00
parent f11313797b
commit 2235516232
18 changed files with 418 additions and 46 deletions
+15
View File
@@ -80,3 +80,18 @@ func (p *ProductApi) QueryInfo(context *gin.Context) {
productInfo, errCode := p.productService.QueryInfo(&param)
response.Result(errCode, productInfo, context)
}
// 导出Excel文件
func (p *ProductApi) Export(context *gin.Context) {
uid, _ := strconv.Atoi(context.Request.Header.Get("uid"))
if uid <= 0 {
response.Result(response.ErrCodeParamInvalid, nil, context)
return
}
file, errCode := p.productService.Export(int64(uid))
if len(file) >= 0 && errCode != 0 {
response.Result(errCode, nil, context)
return
}
context.File(file)
}