tenant

package
v0.4.8-gz9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TenantColumn = "tenant_id"
View Source
const TenantKey = "X-Tenant-ID"

Variables

This section is empty.

Functions

func BeforeQuery

func BeforeQuery(db *gorm.DB)

func DoBeforeQuery

func DoBeforeQuery(tx *gorm.DB) error

func ParseFromMD

func ParseFromMD(key string, md metadata.MD) []string

func ParseTenantIDFromMD

func ParseTenantIDFromMD(md metadata.MD) *string

func RegisterBeforeQuery

func RegisterBeforeQuery(db *gorm.DB)

func WithTenantContext

func WithTenantContext(ctx context.Context, md metadata.MD) context.Context

Types

type BeforeQueryInterface

type BeforeQueryInterface interface {
	BeforeQuery(db *gorm.DB) error
}

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL