From 839a4905337a92f43b8af23da11f439640b0d897 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Fri, 6 Dec 2024 09:06:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/service/export.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/service/export.go b/api/service/export.go index 93a8878..c937298 100644 --- a/api/service/export.go +++ b/api/service/export.go @@ -1,6 +1,7 @@ package service import ( + "encoding/json" "fmt" "github.com/shopspring/decimal" "hospital-admin-api/api/dao" @@ -1656,6 +1657,15 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) { dataSlice = append(dataSlice, data) } + // 转为 JSON + jsonData, err := json.MarshalIndent(dataSlice, "", " ") + if err != nil { + fmt.Println("Error converting to JSON:", err) + return "", err + } + + utils.LogJsonInfo("打印数据:", jsonData) + file, err := utils.Export(header, dataSlice) if err != nil { return "", err From e0e1e6468cbdd4189107d4b4600189548fe69503 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Fri, 6 Dec 2024 09:10:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=89=93=E5=8D=B01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/service/export.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/service/export.go b/api/service/export.go index c937298..d7b3351 100644 --- a/api/service/export.go +++ b/api/service/export.go @@ -1658,7 +1658,7 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) { } // 转为 JSON - jsonData, err := json.MarshalIndent(dataSlice, "", " ") + jsonData, err := json.Marshal(dataSlice) if err != nil { fmt.Println("Error converting to JSON:", err) return "", err From 0334f9125141ea2f9d64023c4bf961eb992741a1 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Fri, 6 Dec 2024 09:13:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=89=93=E5=8D=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/service/export.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/api/service/export.go b/api/service/export.go index d7b3351..38b79aa 100644 --- a/api/service/export.go +++ b/api/service/export.go @@ -1,7 +1,6 @@ package service import ( - "encoding/json" "fmt" "github.com/shopspring/decimal" "hospital-admin-api/api/dao" @@ -1657,14 +1656,7 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) { dataSlice = append(dataSlice, data) } - // 转为 JSON - jsonData, err := json.Marshal(dataSlice) - if err != nil { - fmt.Println("Error converting to JSON:", err) - return "", err - } - - utils.LogJsonInfo("打印数据:", jsonData) + utils.LogJsonInfo("打印数据:", dataSlice) file, err := utils.Export(header, dataSlice) if err != nil { From 34600c43073b6f19d848404a01e34f570c2d1c07 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Fri, 6 Dec 2024 09:30:06 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=89=93=E5=8D=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/service/export.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/service/export.go b/api/service/export.go index 38b79aa..2870f13 100644 --- a/api/service/export.go +++ b/api/service/export.go @@ -1,6 +1,7 @@ package service import ( + "encoding/json" "fmt" "github.com/shopspring/decimal" "hospital-admin-api/api/dao" @@ -1656,7 +1657,14 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) { dataSlice = append(dataSlice, data) } - utils.LogJsonInfo("打印数据:", dataSlice) + // 转为 JSON + jsonData, err := json.Marshal(dataSlice) + if err != nil { + fmt.Println("Error converting to JSON:", err) + return "", err + } + + utils.LogJsonInfo("打印数据:", string(jsonData)) file, err := utils.Export(header, dataSlice) if err != nil {