调整整体架构写法

调整db用法
调整日志用法
调整模版
This commit is contained in:
linwenxiang committed 2021-03-04 23:45:16 +08:00
1 parent 734a48dbb8
commit e2952fa393
137 files changed
+3638 -3544

No files matched your search

+7 -9
View File
@@ -5,7 +5,6 @@ import (
"gorm.io/gorm"
orm "go-admin/common/global"
"go-admin/tools"
config2 "go-admin/tools/config"
)
@@ -20,13 +19,13 @@ type DBTables struct {
TableComment string `gorm:"column:TABLE_COMMENT" json:"tableComment"`
}
func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int, error) {
func (e *DBTables) GetPage(tx *gorm.DB, pageSize int, pageIndex int) ([]DBTables, int, error) {
var doc []DBTables
table := new(gorm.DB)
var count int64
if config2.DatabaseConfig.Driver == "mysql" {
table = orm.Eloquent.Table("information_schema.tables")
table = tx.Table("information_schema.tables")
table = table.Where("TABLE_NAME not in (select table_name from `" + config2.GenConfig.DBName + "`.sys_tables) ")
table = table.Where("table_schema= ? ", config2.GenConfig.DBName)
@@ -44,21 +43,20 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int, error)
return doc, int(count), nil
}
func (e *DBTables) Get() (DBTables, error) {
func (e *DBTables) Get(tx *gorm.DB) (DBTables, error) {
var doc DBTables
table := new(gorm.DB)
if config2.DatabaseConfig.Driver == "mysql" {
table = orm.Eloquent.Table("information_schema.tables")
table := tx.Table("information_schema.tables")
table = table.Where("table_schema= ? ", config2.GenConfig.DBName)
if e.TableName == "" {
return doc, errors.New("table name cannot be empty!")
}
table = table.Where("TABLE_NAME = ?", e.TableName)
if err := table.First(&doc).Error; err != nil {
return doc, err
}
} else {
tools.Assert(true, "目前只支持mysql数据库", 500)
}
if err := table.First(&doc).Error; err != nil {
return doc, err
}
return doc, nil
}