2024-12-17 22:47:16 +08:00
|
|
|
package mySql
|
|
|
|
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
|
|
|
|
type Facade struct {
|
|
|
|
tableName string
|
|
|
|
dbFunc func() *gorm.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFacade(tableName string, dbFunc func() *gorm.DB) *Facade {
|
|
|
|
return &Facade{tableName: tableName, dbFunc: dbFunc}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Facade) NewQuery() *Query {
|
2024-12-18 03:08:49 +08:00
|
|
|
return NewQuery(t.tableName, t.dbFunc())
|
2024-12-17 22:47:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Facade) NewUpdate() *Update {
|
2024-12-18 03:08:49 +08:00
|
|
|
return NewUpdate(t.tableName, t.dbFunc())
|
2024-12-17 22:47:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Facade) NewInsert() *Insert {
|
2024-12-18 03:08:49 +08:00
|
|
|
return NewInsert(t.tableName, t.dbFunc())
|
2024-12-17 22:47:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Facade) NewDelete() *Delete {
|
2024-12-18 03:08:49 +08:00
|
|
|
return NewDelete(t.tableName, t.dbFunc())
|
2024-12-17 22:47:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Facade) Create(val interface{}) error {
|
2024-12-18 03:08:49 +08:00
|
|
|
return Create(val, t.dbFunc())
|
2024-12-17 22:47:16 +08:00
|
|
|
}
|