From 43b1b859c386386af08af1affb9c266022ffbc52 Mon Sep 17 00:00:00 2001 From: "cnb.asek4HHRAKA" Date: Wed, 1 Oct 2025 21:05:42 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BC=98=E5=8C=96=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8=20switch=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=20if-else=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8C=85=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/import.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/service/import.go b/service/import.go index 36f77a9..b49d1b1 100644 --- a/service/import.go +++ b/service/import.go @@ -4,13 +4,14 @@ import ( "bufio" "encoding/csv" "errors" - "github.com/beancount-gs/script" - "github.com/gin-gonic/gin" - "golang.org/x/text/encoding/simplifiedchinese" "io" "strconv" "strings" "time" + + "github.com/beancount-gs/script" + "github.com/gin-gonic/gin" + "golang.org/x/text/encoding/simplifiedchinese" ) func ImportAliPayCSV(c *gin.Context) { @@ -64,11 +65,12 @@ func importBrowserAliPayCSV(lines []string, currency string, currencySymbol stri dateColumn := strings.Fields(lines[2]) status := strings.Trim(lines[15], " ") account := "" - if status == "" { + switch status { + case "": account = "" - } else if status == "已收入" { + case "已收入": account = "Income:" - } else { + default: account = "Expenses:" } @@ -91,12 +93,13 @@ func importMobileAliPayCSV(lines []string, currency string, currencySymbol strin dateColumn := strings.Fields(lines[0]) status := strings.Trim(lines[5], " ") account := "" - if status == "" { + switch status { + case "": account = "" - } else if status == "支出" { - account = "Expenses:" - } else { + case "已收入": account = "Income:" + default: + account = "Expenses:" } if len(dateColumn) >= 2 { @@ -137,12 +140,13 @@ func ImportWxPayCSV(c *gin.Context) { fields := strings.Fields(lines[0]) status := strings.Trim(lines[4], " ") account := "" - if status == "收入" { + switch status { + case "收入": account = "Income:" - } else if status == "支出" { + case "支出": account = "Expenses:" - } else { - continue + default: + account = "" } if len(fields) >= 2 {