1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 01:20:55 +00:00

delete interface

This commit is contained in:
jianzhiyao 2020-09-16 19:46:14 +08:00
parent 5995b00fa2
commit b7bc57c4d1
5 changed files with 0 additions and 64 deletions

View File

@ -30,18 +30,6 @@ var _ Ormer = new(DoNothingOrm)
type DoNothingOrm struct {
}
func (d *DoNothingOrm) RegisterModels(models ...interface{}) (err error) {
return nil
}
func (d *DoNothingOrm) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) {
return nil
}
func (d *DoNothingOrm) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) {
return nil
}
func (d *DoNothingOrm) Read(md interface{}, cols ...string) error {
return nil
}

View File

@ -17,7 +17,6 @@ package orm
import (
"context"
"database/sql"
"errors"
"reflect"
"time"
@ -43,18 +42,6 @@ type filterOrmDecorator struct {
txName string
}
func (f *filterOrmDecorator) RegisterModels(models ...interface{}) (err error) {
return errors.New(`not callable`)
}
func (f *filterOrmDecorator) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) {
return errors.New(`not callable`)
}
func (f *filterOrmDecorator) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) {
return errors.New(`not callable`)
}
func NewFilterOrmDecorator(delegate Ormer, filterChains ...FilterChain) Ormer {
res := &filterOrmDecorator{
ormer: delegate,

View File

@ -36,15 +36,6 @@ var (
modelCache = NewModelCacheHandler()
)
type modelCacheHandler interface {
//RegisterModels register models without prefix or suffix
RegisterModels(models ...interface{}) (err error)
//RegisterModelsWithPrefix register models with prefix
RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error)
//RegisterModelsWithSuffix register models with suffix
RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error)
}
// model info collection
type _modelCache struct {
sync.RWMutex // only used outsite for bootStrap
@ -62,20 +53,6 @@ func NewModelCacheHandler() *_modelCache {
}
}
var _ modelCacheHandler = new(_modelCache)
func (mc *_modelCache) RegisterModels(models ...interface{}) (err error) {
return mc.register(``, true, models...)
}
func (mc *_modelCache) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) {
return mc.register(prefix, true, models...)
}
func (mc *_modelCache) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) {
return mc.register(suffix, false, models...)
}
// get all model info
func (mc *_modelCache) all() map[string]*modelInfo {
m := make(map[string]*modelInfo, len(mc.cache))

View File

@ -496,23 +496,10 @@ func (o *ormBase) DBStats() *sql.DBStats {
type orm struct {
ormBase
modelCacheHandler
}
var _ Ormer = new(orm)
func (o *orm) RegisterModels(models ...interface{}) (err error) {
return o.modelCacheHandler.RegisterModels(models)
}
func (o *orm) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) {
return o.modelCacheHandler.RegisterModelsWithPrefix(prefix, models...)
}
func (o *orm) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) {
return o.modelCacheHandler.RegisterModelsWithSuffix(suffix, models...)
}
func (o *orm) Begin() (TxOrmer, error) {
return o.BeginWithCtx(context.Background())
}
@ -633,8 +620,6 @@ func newDBWithAlias(al *alias) Ormer {
o.db = al.DB
}
o.modelCacheHandler = NewModelCacheHandler()
if len(globalFilterChains) > 0 {
return NewFilterOrmDecorator(o, globalFilterChains...)
}

View File

@ -219,7 +219,6 @@ type ormer interface {
type Ormer interface {
ormer
modelCacheHandler
TxBeginner
}