gorm升级到v2版本
This commit is contained in:
1 parent
93cfe443d6
commit
60c7496f7b
56 files changed
+630
-477
No files matched your search
@@ -2,10 +2,10 @@ package tools
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/jinzhu/gorm"
|
||||
orm "go-admin/global"
|
||||
"go-admin/tools"
|
||||
config2 "go-admin/tools/config"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DBColumns struct {
|
||||
@@ -25,7 +25,7 @@ type DBColumns struct {
|
||||
|
||||
func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int, error) {
|
||||
var doc []DBColumns
|
||||
var count int
|
||||
var count int64
|
||||
table := new(gorm.DB)
|
||||
|
||||
if config2.DatabaseConfig.Driver == "mysql" {
|
||||
@@ -43,7 +43,7 @@ func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int, erro
|
||||
return nil, 0, err
|
||||
}
|
||||
table.Count(&count)
|
||||
return doc, count, nil
|
||||
return doc, int(count), nil
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ package tools
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/jinzhu/gorm"
|
||||
orm "go-admin/global"
|
||||
"go-admin/tools"
|
||||
config2 "go-admin/tools/config"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DBTables struct {
|
||||
@@ -21,7 +21,7 @@ type DBTables struct {
|
||||
func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int, error) {
|
||||
var doc []DBTables
|
||||
table := new(gorm.DB)
|
||||
var count int
|
||||
var count int64
|
||||
|
||||
if config2.DatabaseConfig.Driver == "mysql" {
|
||||
table = orm.Eloquent.Select("*").Table("information_schema.tables")
|
||||
@@ -39,7 +39,7 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int, error)
|
||||
}
|
||||
|
||||
table.Count(&count)
|
||||
return doc, count, nil
|
||||
return doc, int(count), nil
|
||||
}
|
||||
|
||||
func (e *DBTables) Get() (DBTables, error) {
|
||||
|
||||
@@ -61,13 +61,13 @@ func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int, erro
|
||||
table = table.Where("table_comment = ?", e.TableComment)
|
||||
}
|
||||
|
||||
var count int
|
||||
var count int64
|
||||
|
||||
if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
table.Where("`deleted_at` IS NULL").Count(&count)
|
||||
return doc, count, nil
|
||||
return doc, int(count), nil
|
||||
}
|
||||
|
||||
func (e *SysTables) Get() (SysTables, error) {
|
||||
|
||||
Reference in new issue
Block a user