Documentation ¶
Index ¶
- Constants
- func BeforeQuery(db *gorm.DB)
- func DoBeforeQuery(tx *gorm.DB) error
- func ParseFromMD(key string, md metadata.MD) []string
- func ParseTenantIDFromMD(md metadata.MD) *string
- func RegisterBeforeQuery(db *gorm.DB)
- func WithTenantContext(ctx context.Context, md metadata.MD) context.Context
- type BeforeQueryInterface
- type TenantHooks
- func (u *TenantHooks) BeforeCreate(tx *gorm.DB) (err error)
- func (u *TenantHooks) BeforeDelete(tx *gorm.DB) (err error)
- func (u *TenantHooks) BeforeSave(tx *gorm.DB) (err error)
- func (u *TenantHooks) BeforeUpdate(tx *gorm.DB) (err error)
- func (u *TenantHooks) DoBeforeQuery(tx *gorm.DB, err error) error
- func (u *TenantHooks) GetTenantID(tx *gorm.DB) (*string, error)
Constants ¶
View Source
const TenantColumn = "tenant_id"
View Source
const TenantKey = "X-Tenant-ID"
Variables ¶
This section is empty.
Functions ¶
func BeforeQuery ¶
func DoBeforeQuery ¶
func ParseTenantIDFromMD ¶
func RegisterBeforeQuery ¶
Types ¶
type BeforeQueryInterface ¶
type TenantHooks ¶
type TenantHooks struct {
TenantID string `gorm:"column:tenant_id;type:character varying(64);not null" json:"tenant_id"` // 标签名称
}
func (*TenantHooks) BeforeCreate ¶
func (u *TenantHooks) BeforeCreate(tx *gorm.DB) (err error)
func (*TenantHooks) BeforeDelete ¶
func (u *TenantHooks) BeforeDelete(tx *gorm.DB) (err error)
func (*TenantHooks) BeforeSave ¶
func (u *TenantHooks) BeforeSave(tx *gorm.DB) (err error)
func (*TenantHooks) BeforeUpdate ¶
func (u *TenantHooks) BeforeUpdate(tx *gorm.DB) (err error)
func (*TenantHooks) DoBeforeQuery ¶
func (u *TenantHooks) DoBeforeQuery(tx *gorm.DB, err error) error
func (*TenantHooks) GetTenantID ¶
func (u *TenantHooks) GetTenantID(tx *gorm.DB) (*string, error)
Click to show internal directories.
Click to hide internal directories.