Files
jbxh-server/models/tools/dbtables.go
T
2020-03-19 22:04:38 +08:00

34 lines
1022 B
Go

package tools
import (
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"`
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"`
}
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'")
if e.TableName != "" {
table = table.Where("TABLE_NAME = ?", e.TableName)
}
var count int32
if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
return nil, 0, err
}
table.Count(&count)
return doc, count, nil
}