From 779305d6b5ce0539d2c14cd2f08c37ea88bc413e Mon Sep 17 00:00:00 2001 From: "mengkang.zmk" Date: Thu, 16 Jun 2022 14:09:09 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=90=8C=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/templates/admin/admin_modify_password.html | 7 +++++-- assets/templates/index/index.html | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/templates/admin/admin_modify_password.html b/assets/templates/admin/admin_modify_password.html index 7125c632..d9c47a58 100644 --- a/assets/templates/admin/admin_modify_password.html +++ b/assets/templates/admin/admin_modify_password.html @@ -132,8 +132,11 @@ okay: { text: '关闭', action: function () { - parent.window.close(); - window.open("/login"); + if (window.frames.length !== parent.frames.length) { + parent.window.open("/login",'_self'); + }else{ + window.open("/login",'_self'); + } } } } diff --git a/assets/templates/index/index.html b/assets/templates/index/index.html index 1b22b4e0..43b5347b 100644 --- a/assets/templates/index/index.html +++ b/assets/templates/index/index.html @@ -281,8 +281,11 @@ $.cookie('_nav_title_', ''); $.cookie('_login_token_', ''); - parent.window.close(); - window.open("/login"); + if (window.frames.length !== parent.frames.length) { + parent.window.open("/login",'_self'); + }else{ + window.open("/login",'_self'); + } }, function (response) { AjaxError(response); From da0ef964bbfe027bb4d95329c830ed56ce95c814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B0=E4=BA=AE?= Date: Sun, 3 Jul 2022 13:23:53 +0800 Subject: [PATCH 02/13] =?UTF-8?q?fix(1.2.8):=20=E4=BF=AE=E5=A4=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90=20swagger=20doc=20=E5=90=8E=EF=BC=8C=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs.go | 84 ++++++++++++++++--------------- docs/swagger.json | 84 ++++++++++++++++--------------- docs/swagger.yaml | 53 +++++++++---------- internal/api/cron/func_execute.go | 2 +- internal/api/cron/handler.go | 2 +- scripts/restart.sh | 16 ------ scripts/swagger.bat | 2 +- scripts/swagger.sh | 2 +- 8 files changed, 117 insertions(+), 128 deletions(-) delete mode 100755 scripts/restart.sh diff --git a/docs/docs.go b/docs/docs.go index 8a5d1d93..ef409568 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1232,6 +1232,49 @@ var doc = `{ } } }, + "/api/cron/exec/{id}": { + "patch": { + "security": [ + { + "LoginToken": [] + } + ], + "description": "手动执行单条任务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "API.cron" + ], + "summary": "手动执行单条任务", + "parameters": [ + { + "type": "string", + "description": "hashId", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/cron.detailResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/code.Failure" + } + } + } + } + }, "/api/cron/used": { "patch": { "security": [ @@ -1457,47 +1500,6 @@ var doc = `{ } } } - }, - "patch": { - "security": [ - { - "LoginToken": [] - } - ], - "description": "手动执行单条任务", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "API.cron" - ], - "summary": "手动执行单条任务", - "parameters": [ - { - "type": "string", - "description": "hashId", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cron.detailResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/code.Failure" - } - } - } } }, "/api/login": { diff --git a/docs/swagger.json b/docs/swagger.json index e148093f..85b1c6a6 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1216,6 +1216,49 @@ } } }, + "/api/cron/exec/{id}": { + "patch": { + "security": [ + { + "LoginToken": [] + } + ], + "description": "手动执行单条任务", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "API.cron" + ], + "summary": "手动执行单条任务", + "parameters": [ + { + "type": "string", + "description": "hashId", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/cron.detailResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/code.Failure" + } + } + } + } + }, "/api/cron/used": { "patch": { "security": [ @@ -1441,47 +1484,6 @@ } } } - }, - "patch": { - "security": [ - { - "LoginToken": [] - } - ], - "description": "手动执行单条任务", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "API.cron" - ], - "summary": "手动执行单条任务", - "parameters": [ - { - "type": "string", - "description": "hashId", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/cron.detailResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/code.Failure" - } - } - } } }, "/api/login": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d72d09be..aa5f91d9 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1477,32 +1477,6 @@ paths: summary: 获取单条任务详情 tags: - API.cron - patch: - consumes: - - application/json - description: 手动执行单条任务 - parameters: - - description: hashId - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/cron.detailResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/code.Failure' - security: - - LoginToken: [] - summary: 手动执行单条任务 - tags: - - API.cron post: consumes: - application/x-www-form-urlencoded @@ -1594,6 +1568,33 @@ paths: summary: 编辑任务 tags: - API.cron + /api/cron/exec/{id}: + patch: + consumes: + - application/json + description: 手动执行单条任务 + parameters: + - description: hashId + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/cron.detailResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/code.Failure' + security: + - LoginToken: [] + summary: 手动执行单条任务 + tags: + - API.cron /api/cron/used: patch: consumes: diff --git a/internal/api/cron/func_execute.go b/internal/api/cron/func_execute.go index 60f56d7c..1a5e186d 100755 --- a/internal/api/cron/func_execute.go +++ b/internal/api/cron/func_execute.go @@ -27,7 +27,7 @@ type executeResponse struct { // @Param id path string true "hashId" // @Success 200 {object} detailResponse // @Failure 400 {object} code.Failure -// @Router /api/cron/{id} [patch] +// @Router /api/cron/exec/{id} [patch] // @Security LoginToken func (h *handler) Execute() core.HandlerFunc { return func(ctx core.Context) { diff --git a/internal/api/cron/handler.go b/internal/api/cron/handler.go index 7b6c66dd..69de4aaf 100644 --- a/internal/api/cron/handler.go +++ b/internal/api/cron/handler.go @@ -44,7 +44,7 @@ type Handler interface { // Execute 手动执行任务 // @Tags API.cron - // @Router /api/cron/{id} [patch] + // @Router /api/cron/exec/{id} [patch] Execute() core.HandlerFunc } diff --git a/scripts/restart.sh b/scripts/restart.sh deleted file mode 100755 index ea19f4ca..00000000 --- a/scripts/restart.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -shellExit() -{ -if [ $1 -eq 1 ]; then - printf "\nfailed!!!\n\n" - exit 1 -fi -} - -printf "\nRestart server port:9999 \n\n" - -lsof -i:9999 | grep LISTEN | awk '{print $2}' | xargs kill -s SIGINT && go run ./main.go -env fat -shellExit $? - -printf "\nDone.\n\n" diff --git a/scripts/swagger.bat b/scripts/swagger.bat index 0f077b81..91f1f089 100644 --- a/scripts/swagger.bat +++ b/scripts/swagger.bat @@ -3,7 +3,7 @@ chcp 65001 echo. echo Regenerating swagger doc echo. -go install github.com/swaggo/swag/cmd/swag@latest +go install github.com/swaggo/swag/cmd/swag@v1.7.4 swag init echo. echo Done. \ No newline at end of file diff --git a/scripts/swagger.sh b/scripts/swagger.sh index cd292259..9ebbaf2b 100755 --- a/scripts/swagger.sh +++ b/scripts/swagger.sh @@ -1,5 +1,5 @@ #!/bin/bash printf "\nRegenerating swagger doc\n\n" -go install github.com/swaggo/swag/cmd/swag@latest +go install github.com/swaggo/swag/cmd/swag@v1.7.4 time swag init printf "\nDone.\n\n" \ No newline at end of file From b890f96acf868c76664388f862162b14e26048b9 Mon Sep 17 00:00:00 2001 From: "mengkang.zmk" Date: Fri, 24 Jun 2022 13:57:12 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + logs/go-gin-api-access.log | 0 logs/go-gin-api-cron.log | 0 3 files changed, 1 insertion(+) delete mode 100755 logs/go-gin-api-access.log delete mode 100755 logs/go-gin-api-cron.log diff --git a/.gitignore b/.gitignore index aedf6924..9116c005 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ +logs/ \ No newline at end of file diff --git a/logs/go-gin-api-access.log b/logs/go-gin-api-access.log deleted file mode 100755 index e69de29b..00000000 diff --git a/logs/go-gin-api-cron.log b/logs/go-gin-api-cron.log deleted file mode 100755 index e69de29b..00000000 From 7049cd4d4569218527989bdd6ee1c9c56d1885ea Mon Sep 17 00:00:00 2001 From: "mengkang.zmk" Date: Fri, 24 Jun 2022 14:11:41 +0800 Subject: [PATCH 04/13] Changes --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9116c005..8c830d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ -logs/ \ No newline at end of file +logs/* \ No newline at end of file From 4e6d9780050248003d27c55024fa1bb38d11f4d7 Mon Sep 17 00:00:00 2001 From: "mengkang.zmk" Date: Thu, 21 Jul 2022 15:55:42 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E6=B8=85=E7=A9=BA=20logs=20=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logs/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 logs/.gitkeep diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 00000000..e69de29b From 8bdbda180e4decc138a1b430df0283198eae4679 Mon Sep 17 00:00:00 2001 From: "mengkang.zmk" Date: Sun, 24 Jul 2022 09:03:27 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=B8=85=E7=A9=BA=20logs=20=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8c830d3b..16a89aef 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ -logs/* \ No newline at end of file + +# Project runtime log +logs/*.log \ No newline at end of file From addbab843ea785f587096214ab010573ca97b30d Mon Sep 17 00:00:00 2001 From: lileibiao Date: Sat, 8 Oct 2022 19:49:14 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=94=AF=E6=8C=81pgsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INSTALL.lock | 0 assets/templates/install/install_view.html | 162 ++++--- cmd/pgsqlcmd/main.go | 429 ++++++++++++++++++ cmd/pgsqlcmd/pgsql/pgsql.go | 65 +++ configs/configs.go | 25 + configs/fat_configs.toml | 32 +- go.mod | 1 + go.sum | 109 ++++- internal/api/admin/handler.go | 4 +- internal/api/authorized/handler.go | 4 +- internal/api/config/handler.go | 4 +- internal/api/cron/handler.go | 4 +- internal/api/helper/handler.go | 6 +- internal/api/menu/handler.go | 4 +- internal/api/tool/handler.go | 6 +- internal/code/code.go | 1 + internal/graph/handler/handler.go | 6 +- internal/graph/resolvers/resolvers.go | 4 +- internal/proposal/tablesqls/table_admin.go | 129 +++++- .../proposal/tablesqls/table_admin_menu.go | 123 +++++ .../proposal/tablesqls/table_authorized.go | 86 ++++ .../tablesqls/table_authorized_api.go | 119 +++++ .../proposal/tablesqls/table_cron_task.go | 169 +++++++ internal/proposal/tablesqls/table_menu.go | 172 +++++++ .../proposal/tablesqls/table_menu_action.go | 168 +++++++ internal/render/admin/admin.go | 6 +- internal/render/authorized/authorized.go | 6 +- internal/render/config/config.go | 4 +- internal/render/cron/cron.go | 6 +- internal/render/dashboard/dashboard.go | 6 +- internal/render/generator/generator.go | 6 +- internal/render/generator/gorm_execute.go | 35 +- internal/render/generator/gorm_view.go | 17 +- internal/render/index/index.go | 6 +- internal/render/install/execute.go | 154 +++++-- internal/render/tool/tool.go | 4 +- internal/render/upgrade/upgrade.go | 6 +- internal/repository/cron/cron.go | 6 +- internal/repository/db/getDB.go | 20 + internal/repository/iface/database_repo.go | 10 + internal/repository/mysql/admin/gen_model.go | 1 + .../repository/mysql/admin_menu/gen_model.go | 1 + .../repository/mysql/authorized/gen_model.go | 1 + .../mysql/authorized_api/gen_model.go | 1 + .../repository/mysql/cron_task/gen_model.go | 1 + internal/repository/mysql/menu/gen_model.go | 1 + .../repository/mysql/menu_action/gen_model.go | 1 + internal/repository/mysql/mysql.go | 13 +- internal/repository/pgsql/cc/gen_cc.go | 163 +++++++ internal/repository/pgsql/cc/gen_model.go | 8 + internal/repository/pgsql/cc/gen_table.md | 6 + internal/repository/pgsql/pgsql.go | 124 +++++ internal/repository/socket/socket.go | 6 +- internal/router/interceptor/interceptor.go | 6 +- internal/router/router.go | 9 +- internal/services/admin/service.go | 6 +- internal/services/authorized/service.go | 6 +- internal/services/cron/service.go | 6 +- internal/services/menu/service.go | 6 +- internal/websocket/sysmessage/sysmessage.go | 6 +- pkg/color/string_darwin.go | 1 + pkg/color/string_linux.go | 1 + pkg/color/string_windows.go | 1 + scripts/pgsqlgormgen.bat | 50 ++ scripts/pgsqlgormgen.sh | 37 ++ 65 files changed, 2372 insertions(+), 214 deletions(-) create mode 100644 INSTALL.lock create mode 100644 cmd/pgsqlcmd/main.go create mode 100644 cmd/pgsqlcmd/pgsql/pgsql.go create mode 100644 internal/repository/db/getDB.go create mode 100644 internal/repository/iface/database_repo.go create mode 100755 internal/repository/pgsql/cc/gen_cc.go create mode 100755 internal/repository/pgsql/cc/gen_model.go create mode 100755 internal/repository/pgsql/cc/gen_table.md create mode 100644 internal/repository/pgsql/pgsql.go create mode 100644 scripts/pgsqlgormgen.bat create mode 100644 scripts/pgsqlgormgen.sh diff --git a/INSTALL.lock b/INSTALL.lock new file mode 100644 index 00000000..e69de29b diff --git a/assets/templates/install/install_view.html b/assets/templates/install/install_view.html index 3158452c..39158e88 100644 --- a/assets/templates/install/install_view.html +++ b/assets/templates/install/install_view.html @@ -14,6 +14,13 @@ + @@ -27,7 +34,8 @@
检测 · 环境
-

所需版本:go{{.MinGoVersion}}+ (当前版本 {{.GoVersion}})

+

所需版本:go{{.MinGoVersion}}+ (当前版本 {{.GoVersion}}) +

配置 · 语言
@@ -67,42 +75,57 @@
配置 · Redis
-
配置 · MySQL
+
配置 · 数据库
- 地址 + 数据库类型
- +
- -
-
- 用户 +
+
+
+ 地址 +
+
- -
-
-
- 密码 +
+
+ 用户 +
+
- -
-
-
- DB +
+
+ 密码 +
+
- -
- 请确保此数据库已存在! + +
+
+ DB +
+ +
+ 请确保此数据库已存在! +
-
@@ -100,7 +100,7 @@
配置 · 数据库
用户
-
@@ -109,7 +109,7 @@
配置 · 数据库
密码
-
@@ -118,7 +118,7 @@
配置 · 数据库
DB
-
@@ -186,8 +186,8 @@
配置 · 数据库 }); return false; } - const mysql_addr = $("#mysql_addr").val(); - if (mysql_addr === "") { + const database_addr = $("#database_addr").val(); + if (database_addr === "") { $.alert({ title: '温馨提示', icon: 'mdi mdi-alert', @@ -197,8 +197,8 @@
配置 · 数据库 return false; } - const mysql_user = $("#mysql_user").val(); - if (mysql_user === "") { + const database_user = $("#database_user").val(); + if (database_user === "") { $.alert({ title: '温馨提示', icon: 'mdi mdi-alert', @@ -208,8 +208,8 @@
配置 · 数据库 return false; } - const mysql_pass = $("#mysql_pass").val(); - if (mysql_pass === "") { + const database_pass = $("#database_pass").val(); + if (database_pass === "") { $.alert({ title: '温馨提示', icon: 'mdi mdi-alert', @@ -219,8 +219,8 @@
配置 · 数据库 return false; } - const mysql_name = $("#mysql_name").val(); - if (mysql_name === "") { + const database_name = $("#database_name").val(); + if (database_name === "") { $.alert({ title: '温馨提示', icon: 'mdi mdi-alert', @@ -239,10 +239,10 @@
配置 · 数据库 redis_db: redis_db, database_type: $('#database_type').val(), - mysql_addr: mysql_addr, - mysql_user: mysql_user, - mysql_pass: mysql_pass, - mysql_name: mysql_name, + database_addr: database_addr, + database_user: database_user, + database_pass: database_pass, + database_name: database_name, }; console.log('postData', postData); AjaxForm( diff --git a/internal/proposal/tablesqls/table_menu_action.go b/internal/proposal/tablesqls/table_menu_action.go index 647a4b2e..0a6a1076 100644 --- a/internal/proposal/tablesqls/table_menu_action.go +++ b/internal/proposal/tablesqls/table_menu_action.go @@ -155,7 +155,6 @@ func CreateMenuActionTableDataSql() (sql string) { sql += "(7, 2, 'PATCH', '/api/config/email', 'init')," sql += "(8, 5, 'POST', '/generator/gorm/execute', 'init')," sql += "(9, 6, 'POST', '/generator/handler/execute', 'init')," - sql += "(49, 27, 'POST', '/generator/pgsql/gorm/execute', 'init')," sql += "(10, 8, 'GET', '/authorized/add', 'init')," sql += "(11, 8, 'GET', '/authorized/api/*', 'init')," sql += "(12, 8, 'GET', '/api/authorized', 'init')," @@ -210,7 +209,6 @@ func CreateMenuActionTableDataPGSql() (sql string) { sql += "(7, 2, 'PATCH', '/api/config/email', 'init')," sql += "(8, 5, 'POST', '/generator/gorm/execute', 'init')," sql += "(9, 6, 'POST', '/generator/handler/execute', 'init')," - sql += "(49, 27, 'POST', '/generator/pgsql/gorm/execute', 'init')," sql += "(10, 8, 'GET', '/authorized/add', 'init')," sql += "(11, 8, 'GET', '/authorized/api/*', 'init')," sql += "(12, 8, 'GET', '/api/authorized', 'init')," diff --git a/internal/render/install/execute.go b/internal/render/install/execute.go index 2530dcff..6c9e08d6 100644 --- a/internal/render/install/execute.go +++ b/internal/render/install/execute.go @@ -30,10 +30,10 @@ type initExecuteRequest struct { DataBaseType string `form:"database_type"` //连接数据库类型 - MySQLAddr string `form:"mysql_addr"` - MySQLUser string `form:"mysql_user"` - MySQLPass string `form:"mysql_pass"` - MySQLName string `form:"mysql_name"` + DataBaseAddr string `form:"database_addr"` + DataBaseUser string `form:"database_user"` + DataBasePass string `form:"database_pass"` + DataBaseName string `form:"database_name"` } func (h *handler) Execute() core.HandlerFunc { @@ -170,27 +170,27 @@ func (h *handler) Execute() core.HandlerFunc { viper.Set("redis.pass", req.RedisPass) viper.Set("redis.db", req.RedisDb) - viper.Set("mysql.read.addr", req.MySQLAddr) - viper.Set("mysql.read.user", req.MySQLUser) - viper.Set("mysql.read.pass", req.MySQLPass) - viper.Set("mysql.read.name", req.MySQLName) + viper.Set("mysql.read.addr", req.DataBaseAddr) + viper.Set("mysql.read.user", req.DataBaseUser) + viper.Set("mysql.read.pass", req.DataBasePass) + viper.Set("mysql.read.name", req.DataBaseName) - viper.Set("mysql.write.addr", req.MySQLAddr) - viper.Set("mysql.write.user", req.MySQLUser) - viper.Set("mysql.write.pass", req.MySQLPass) - viper.Set("mysql.write.name", req.MySQLName) + viper.Set("mysql.write.addr", req.DataBaseAddr) + viper.Set("mysql.write.user", req.DataBaseUser) + viper.Set("mysql.write.pass", req.DataBasePass) + viper.Set("mysql.write.name", req.DataBaseName) - viper.Set("pgsql.read.addr", strings.Split(req.MySQLAddr, ":")[0]) - viper.Set("pgsql.read.user", req.MySQLUser) - viper.Set("pgsql.read.pass", req.MySQLPass) - viper.Set("pgsql.read.name", req.MySQLName) - viper.Set("pgsql.read.port", strings.Split(req.MySQLAddr, ":")[1]) + viper.Set("pgsql.read.addr", strings.Split(req.DataBaseAddr, ":")[0]) + viper.Set("pgsql.read.user", req.DataBaseUser) + viper.Set("pgsql.read.pass", req.DataBasePass) + viper.Set("pgsql.read.name", req.DataBaseName) + viper.Set("pgsql.read.port", strings.Split(req.DataBaseAddr, ":")[1]) - viper.Set("pgsql.write.addr", strings.Split(req.MySQLAddr, ":")[0]) - viper.Set("pgsql.write.user", req.MySQLUser) - viper.Set("pgsql.write.pass", req.MySQLPass) - viper.Set("pgsql.write.name", req.MySQLName) - viper.Set("pgsql.write.port", strings.Split(req.MySQLAddr, ":")[1]) + viper.Set("pgsql.write.addr", strings.Split(req.DataBaseAddr, ":")[0]) + viper.Set("pgsql.write.user", req.DataBaseUser) + viper.Set("pgsql.write.pass", req.DataBasePass) + viper.Set("pgsql.write.name", req.DataBaseName) + viper.Set("pgsql.write.port", strings.Split(req.DataBaseAddr, ":")[1]) viper.Set("databasetype.type", req.DataBaseType) @@ -264,10 +264,10 @@ func getDB(req initExecuteRequest) (*gorm.DB, error) { case "Mysql": // region 验证 MySQL 配置 dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=%t&loc=%s", - req.MySQLUser, - req.MySQLPass, - req.MySQLAddr, - req.MySQLName, + req.DataBaseUser, + req.DataBasePass, + req.DataBaseAddr, + req.DataBaseName, true, "Local") return gorm.Open(mysql.Open(dsn), &gorm.Config{ @@ -279,13 +279,13 @@ func getDB(req initExecuteRequest) (*gorm.DB, error) { case "Postgresql": // region 验证 PgsqlSQL 配置 pgDsn := fmt.Sprintf("host=%s port=%s user=%s dbname=%s sslmode=%s password=%s", - strings.Split(req.MySQLAddr, ":")[0], - strings.Split(req.MySQLAddr, ":")[1], + strings.Split(req.DataBaseAddr, ":")[0], + strings.Split(req.DataBaseAddr, ":")[1], //req.PgSQLPort, - req.MySQLUser, - req.MySQLName, + req.DataBaseUser, + req.DataBaseName, "disable", - req.MySQLPass, + req.DataBasePass, ) //gorm.Open("postgres", dataSource) return gorm.Open(postgres.Open(pgDsn), &gorm.Config{ From 455026c4aff73cdb95fcb58cfcdb175737005725 Mon Sep 17 00:00:00 2001 From: lileibiao Date: Sun, 9 Oct 2022 18:34:38 +0800 Subject: [PATCH 10/13] =?UTF-8?q?tool=E6=B7=BB=E5=8A=A0pgsql=E8=AF=AD?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INSTALL.lock | 0 assets/templates/tool/tool_data.html | 19 +++++++- configs/fat_configs.toml | 18 ++++---- internal/api/tool/func_dbs.go | 4 +- internal/api/tool/func_tables.go | 16 ++++++- internal/proposal/tablesqls/table_func.go | 53 +++++++++++++++++++++++ internal/render/install/execute.go | 12 +++++ 7 files changed, 108 insertions(+), 14 deletions(-) create mode 100644 INSTALL.lock create mode 100644 internal/proposal/tablesqls/table_func.go diff --git a/INSTALL.lock b/INSTALL.lock new file mode 100644 index 00000000..e69de29b diff --git a/assets/templates/tool/tool_data.html b/assets/templates/tool/tool_data.html index 145756f7..80f7af86 100644 --- a/assets/templates/tool/tool_data.html +++ b/assets/templates/tool/tool_data.html @@ -107,6 +107,7 @@