sql: Refactor use of tables
This commit is contained in:
parent
85fe5b5c5a
commit
73d821e320
19 changed files with 191 additions and 83 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
"github.com/tkw1536/goprogram/lib/reflectx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
|
@ -22,8 +23,16 @@ type Policy struct {
|
|||
var (
|
||||
_ component.Provisionable = (*Policy)(nil)
|
||||
_ component.UserDeleteHook = (*Policy)(nil)
|
||||
_ component.Table = (*Policy)(nil)
|
||||
)
|
||||
|
||||
func (pol *Policy) table(ctx context.Context) (*gorm.DB, error) {
|
||||
return pol.Dependencies.SQL.QueryTable(ctx, true, models.GrantTable)
|
||||
func (pol *Policy) TableInfo() component.TableInfo {
|
||||
return component.TableInfo{
|
||||
Name: models.GrantTable,
|
||||
Model: reflectx.TypeOf[models.Grant](),
|
||||
}
|
||||
}
|
||||
|
||||
func (pol *Policy) table(ctx context.Context) (*gorm.DB, error) {
|
||||
return pol.Dependencies.SQL.QueryTable(ctx, pol)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue