code generation tool
This commit is contained in:
1 parent
1c650ce539
commit
1b03cf2c48
7 files changed
+261
-79
No files matched your search
@@ -1,24 +1,25 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"errors"
|
||||
orm "go-admin/database"
|
||||
)
|
||||
|
||||
type DBTables struct {
|
||||
TableName string `gorm:"column:TABLE_NAME" json:"tableName"`
|
||||
Engine string `gorm:"column:ENGINE" json:"engine"`
|
||||
TableRows string `gorm:"column:TABLE_ROWS" json:"tableRows"`
|
||||
TableName string `gorm:"column:TABLE_NAME" json:"tableName"`
|
||||
Engine string `gorm:"column:ENGINE" json:"engine"`
|
||||
TableRows string `gorm:"column:TABLE_ROWS" json:"tableRows"`
|
||||
TableCollation string `gorm:"column:TABLE_COLLATION" json:"tableCollation"`
|
||||
CreateTime string `gorm:"column:CREATE_TIME" json:"createTime"`
|
||||
UpdateTime string `gorm:"column:UPDATE_TIME" json:"updateTime"`
|
||||
TableComment string `gorm:"column:TABLE_COMMENT" json:"tableComment"`
|
||||
CreateTime string `gorm:"column:CREATE_TIME" json:"createTime"`
|
||||
UpdateTime string `gorm:"column:UPDATE_TIME" json:"updateTime"`
|
||||
TableComment string `gorm:"column:TABLE_COMMENT" json:"tableComment"`
|
||||
}
|
||||
|
||||
func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int32, error) {
|
||||
var doc []DBTables
|
||||
|
||||
table := orm.Eloquent.Select("*").Table("information_schema.tables")
|
||||
table=table.Where("table_schema='test1db'")
|
||||
table = table.Where("table_schema='test1db'")
|
||||
|
||||
if e.TableName != "" {
|
||||
table = table.Where("TABLE_NAME = ?", e.TableName)
|
||||
@@ -31,4 +32,20 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int32, erro
|
||||
}
|
||||
table.Count(&count)
|
||||
return doc, count, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e *DBTables) Get() (DBTables, error) {
|
||||
var doc DBTables
|
||||
|
||||
table := orm.Eloquent.Select("*").Table("information_schema.tables")
|
||||
table = table.Where("table_schema='test1db'")
|
||||
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
|
||||
}
|
||||
return doc, nil
|
||||
}
|
||||
Reference in new issue
Block a user