mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-12-25 07:47:48 +08:00
23 lines
366 B
Go
23 lines
366 B
Go
package repo
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type DBOption func(*gorm.DB) *gorm.DB
|
|
|
|
type ICommonRepo interface {
|
|
WithOrderBy(orderStr string) DBOption
|
|
}
|
|
|
|
type CommonRepo struct{}
|
|
|
|
func NewCommonRepo() ICommonRepo {
|
|
return &CommonRepo{}
|
|
}
|
|
func (c *CommonRepo) WithOrderBy(orderStr string) DBOption {
|
|
return func(g *gorm.DB) *gorm.DB {
|
|
return g.Order(orderStr)
|
|
}
|
|
}
|