From d94863cdf289c261292caeeb8b94833ceaa428d5 Mon Sep 17 00:00:00 2001 From: Jrohy Date: Fri, 1 Jan 2021 12:23:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96sql=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/tools.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/tools.go b/core/tools.go index 1a0f0de6..fe893343 100644 --- a/core/tools.go +++ b/core/tools.go @@ -60,7 +60,7 @@ ADD COLUMN expiryDate char(10) DEFAULT ''; // DumpSql 导出sql func (mysql *Mysql) DumpSql(filePath string) error { - file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 0644) + file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { return err } @@ -75,8 +75,8 @@ func (mysql *Mysql) DumpSql(filePath string) error { } for _, user := range userList { writer.WriteString(fmt.Sprintf(` -INSERT INTO users(id, username, password, passwordShow, quota, download, upload, useDays, expiryDate) VALUES (%d, '%s','%s','%s', %d, %d, %d, %d, '%s');`, - user.ID, user.Username, user.EncryptPass, user.Password, user.Quota, user.Download, user.Upload, user.UseDays, user.ExpiryDate)) +INSERT INTO users(username, password, passwordShow, quota, download, upload, useDays, expiryDate) VALUES ('%s','%s','%s', %d, %d, %d, %d, '%s');`, + user.Username, user.EncryptPass, user.Password, user.Quota, user.Download, user.Upload, user.UseDays, user.ExpiryDate)) } writer.WriteString("\n") writer.Flush()