跟进
This commit is contained in:
@ -12,39 +12,21 @@ func NewFacade(tableName string, dbFunc func() *gorm.DB) *Facade {
|
||||
}
|
||||
|
||||
func (t *Facade) NewQuery() *Query {
|
||||
if t.dbFunc != nil {
|
||||
return NewQuery(t.tableName).SetDB(t.dbFunc())
|
||||
}
|
||||
return NewQuery(t.tableName)
|
||||
return NewQuery(t.tableName, t.dbFunc())
|
||||
}
|
||||
|
||||
func (t *Facade) NewUpdate() *Update {
|
||||
if t.dbFunc != nil {
|
||||
return NewUpdate(t.tableName).SetDB(t.dbFunc())
|
||||
}
|
||||
return NewUpdate(t.tableName)
|
||||
return NewUpdate(t.tableName, t.dbFunc())
|
||||
}
|
||||
|
||||
func (t *Facade) NewInsert() *Insert {
|
||||
if t.dbFunc != nil {
|
||||
return NewInsert(t.tableName).SetDB(t.dbFunc())
|
||||
}
|
||||
return NewInsert(t.tableName)
|
||||
return NewInsert(t.tableName, t.dbFunc())
|
||||
}
|
||||
|
||||
func (t *Facade) NewDelete() *Delete {
|
||||
if t.dbFunc != nil {
|
||||
return NewDelete(t.tableName).SetDB(t.dbFunc())
|
||||
}
|
||||
return NewDelete(t.tableName)
|
||||
return NewDelete(t.tableName, t.dbFunc())
|
||||
}
|
||||
|
||||
func (t *Facade) Create(val interface{}) error {
|
||||
if t.dbFunc != nil {
|
||||
db := t.dbFunc()
|
||||
if db != nil {
|
||||
return Create(val, db)
|
||||
}
|
||||
}
|
||||
return Create(val)
|
||||
return Create(val, t.dbFunc())
|
||||
}
|
||||
|
Reference in New Issue
Block a user