1Panel/core/app/repo/common.go
2024-07-22 16:14:59 +08:00

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)
}
}