This commit is contained in:
wangchuxiao
2023-03-16 20:35:55 +08:00
parent 47637175d7
commit 2966afca6b
2 changed files with 3 additions and 6 deletions
+2 -5
View File
@@ -2,12 +2,13 @@ package relation
import (
"context"
"gorm.io/gorm"
)
type MetaDB struct {
DB *gorm.DB
table interface{}
table any
}
func NewMetaDB(db *gorm.DB, table any) *MetaDB {
@@ -20,7 +21,3 @@ func NewMetaDB(db *gorm.DB, table any) *MetaDB {
func (g *MetaDB) db(ctx context.Context) *gorm.DB {
return g.DB.WithContext(ctx).Model(g.table)
}
func (g *MetaDB) page(pageNumber, showNumber int32) *gorm.DB {
return g.DB.Limit(int(showNumber)).Offset(int(pageNumber*showNumber-1))
}