From bd649546b290812c2026cb99ad51fb49be6d6914 Mon Sep 17 00:00:00 2001 From: fesion Date: Tue, 22 Dec 2020 15:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E7=94=A8=E5=85=B6=E4=BB=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/handler/install.go | 5 ++--- app/request/install.go | 1 - config.dist.json | 1 - config/mysql.go | 1 - services/mysql.go | 7 ------- template/install/index.html | 6 ------ 6 files changed, 2 insertions(+), 19 deletions(-) diff --git a/app/handler/install.go b/app/handler/install.go index 050cc6c..6047b80 100644 --- a/app/handler/install.go +++ b/app/handler/install.go @@ -35,7 +35,7 @@ func InstallForm(ctx iris.Context) { mysqlUrl := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=True&loc=Local", req.User, req.Password, req.Host, req.Port, req.Database, config.MySQLConfig.Charset) - db, err := gorm.Open("mysql", mysqlUrl) + _, err := gorm.Open("mysql", mysqlUrl) if err != nil { ctx.JSON(iris.Map{ "code": config.StatusFailed, @@ -43,14 +43,12 @@ func InstallForm(ctx iris.Context) { }) return } - db.AutoMigrate(&core.Article{}, &core.ArticleData{}, &core.ArticleSource{}) config.JsonData.MySQL.Database = req.Database config.JsonData.MySQL.User = req.User config.JsonData.MySQL.Password = req.Password config.JsonData.MySQL.Host = req.Host config.JsonData.MySQL.Port = req.Port - config.JsonData.MySQL.TablePrefix = req.TablePrefix config.JsonData.MySQL.Url = mysqlUrl err = config.WriteConfig() if err != nil { @@ -63,6 +61,7 @@ func InstallForm(ctx iris.Context) { config.InitJSON() services.InitDB() + services.DB.AutoMigrate(&core.Article{}, &core.ArticleData{}, &core.ArticleSource{}) ctx.JSON(iris.Map{ "code": config.StatusOK, diff --git a/app/request/install.go b/app/request/install.go index 5e72b2a..65d02d7 100644 --- a/app/request/install.go +++ b/app/request/install.go @@ -7,5 +7,4 @@ type Install struct { Host string `form:"host" validate:"required"` Port int `form:"port" validate:"required"` Charset string `form:"charset"` - TablePrefix string `form:"table_prefix" validate:"required"` } diff --git a/config.dist.json b/config.dist.json index ff6f5e2..00fb60d 100644 --- a/config.dist.json +++ b/config.dist.json @@ -6,7 +6,6 @@ "host": "localhost", "port": 3306, "charset": "utf8mb4", - "table_prefix": "fe_", "max_idle_connections": 1000, "max_open_connections": 100000 }, diff --git a/config/mysql.go b/config/mysql.go index 940ad37..dc9a838 100644 --- a/config/mysql.go +++ b/config/mysql.go @@ -7,7 +7,6 @@ type mySQLConfig struct { Host string `json:"host"` Port int `json:"port"` Charset string `json:"charset"` - TablePrefix string `json:"table_prefix"` MaxIdleConnections int `json:"max_idle_connections"` MaxOpenConnections int `json:"max_open_connections"` Url string `json:"-"` diff --git a/services/mysql.go b/services/mysql.go index 1f8df1a..7a08bed 100644 --- a/services/mysql.go +++ b/services/mysql.go @@ -26,13 +26,6 @@ func InitDB() { //禁用复数表名 db.SingularTable(true) - //统一加前缀 - if config.MySQLConfig.TablePrefix != "" { - gorm.DefaultTableNameHandler = func(db *gorm.DB, defaultTableName string) string { - return config.MySQLConfig.TablePrefix + defaultTableName - } - } - DB = db } } diff --git a/template/install/index.html b/template/install/index.html index c2e0a92..32e3954 100644 --- a/template/install/index.html +++ b/template/install/index.html @@ -33,12 +33,6 @@

初始化采集工具

-
- -
- -
-