From 63b497c49702b932b4a8b6f9d04c2204110bd3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 15 May 2022 20:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=85=A8=E9=83=A8=E8=A1=A8=E7=9A=84=E8=83=BD?= =?UTF-8?q?=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 system.go diff --git a/system.go b/system.go new file mode 100644 index 0000000..bb782b2 --- /dev/null +++ b/system.go @@ -0,0 +1,37 @@ +// Package mysql ... +// +// Description : mysql ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2022-05-15 19:32 +package mysql + +import ( + "gorm.io/gorm" +) + +// SystemDao 执行一些系统的mysql命令 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:32 2022/5/15 +type SystemDao struct { +} + +// GetTableList 查询数据表 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:36 2022/5/15 +func (sd *SystemDao) GetTableList(dbInstance *gorm.DB) ([]string, error) { + var ( + err error + result []string + ) + + if err = dbInstance.Raw("SHOW TABLES").Scan(&result).Error; nil != err { + return nil, err + } + return result, nil +}