biz

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 17 Imported by: 2

README

Biz

Documentation

Index

Constants

View Source
const ConnName dal.ConnName = "saas"

Variables

ProviderSet is biz providers.

Functions

func LogoBlob

func LogoBlob(ctx context.Context, factory blob.Factory) blob.Blob

Types

type AdminInfo

type AdminInfo struct {
	Username string
	Email    string
	Password string
}

type ConfigConnStrGenerator

type ConfigConnStrGenerator struct {
	// contains filtered or unexported fields
}

func (*ConfigConnStrGenerator) Generate

func (c *ConfigConnStrGenerator) Generate(ctx context.Context, tenant *Tenant) ([]TenantConn, error)

type ConnStrGenerator

type ConnStrGenerator interface {
	//Generate connection string for tenant before creation
	Generate(ctx context.Context, tenant *Tenant) ([]TenantConn, error)
}

func NewConfigConnStrGenerator

func NewConfigConnStrGenerator(saasConf *conf.SaasConf) ConnStrGenerator

type Tenant

type Tenant struct {
	gorm2.UIDBase
	concurrency.Version
	//unique name. usually for domain name
	Name string `gorm:"column:name;index;size:255;"`
	//localed display name
	DisplayName string `gorm:"column:display_name;index;size:255;"`
	//region of this tenant
	Region     string `gorm:"column:region;index;size:255;"`
	CreatedAt  time.Time    `gorm:"column:created_at;index;"`
	UpdatedAt  time.Time    `gorm:"column:updated_at;index;"`
	DeletedAt  gg.DeletedAt `gorm:"column:deleted_at;index;"`
	SeparateDb bool
	//connection
	Conn []TenantConn `gorm:"foreignKey:TenantId"`
	//edition
	Features []TenantFeature `gorm:"foreignKey:TenantId"`
	Extra    data.JSONMap
}

type TenantConn

type TenantConn struct {
	TenantId string `gorm:"column:tenant_id;primary_key;size:36;"`
	//key of connection string
	Key string `gorm:"column:key;primary_key;size:100;"`
	//connection string
	Value     string    `gorm:"column:value;size:1000;"`
	CreatedAt time.Time `gorm:"column:created_at;index;"`
	UpdatedAt time.Time `gorm:"column:updated_at;index;"`
	Ready     bool      `gorm:"column:ready"`
}

TenantConn connection string info

type TenantFeature

type TenantFeature struct {
	TenantId string `gorm:"column:tenant_id;primary_key;size:36;"`
	//key of connection string
	Key string `gorm:"column:key;primary_key;size:100;"`
	//connection string
	Value     string    `gorm:"column:value;size:1000;"`
	CreatedAt time.Time `gorm:"column:created_at;index;"`
	UpdatedAt time.Time `gorm:"column:updated_at;index;"`
}

type TenantReadyEventHandler

type TenantReadyEventHandler event.ConsumerHandler

func NewTenantReadyEventHandler

func NewTenantReadyEventHandler(useCase *TenantUseCase) TenantReadyEventHandler

type TenantRepo

type TenantRepo interface {
	data.Repo[Tenant, string, v1.ListTenantRequest]
	FindByIdOrName(ctx context.Context, idOrName string) (*Tenant, error)
}

type TenantUseCase

type TenantUseCase struct {
	// contains filtered or unexported fields
}

func NewTenantUserCase

func NewTenantUserCase(repo TenantRepo, connStrGenerator ConnStrGenerator, sender event.Producer) *TenantUseCase

func (*TenantUseCase) Count

func (t *TenantUseCase) Count(ctx context.Context, query *v1.ListTenantRequest) (total int64, filtered int64, err error)

func (*TenantUseCase) Create

func (t *TenantUseCase) Create(ctx context.Context, entity *Tenant) error

func (*TenantUseCase) CreateWithAdmin

func (t *TenantUseCase) CreateWithAdmin(ctx context.Context, entity *Tenant, adminInfo *AdminInfo) error

func (*TenantUseCase) Delete

func (t *TenantUseCase) Delete(ctx context.Context, id string) error

func (*TenantUseCase) FindByIdOrName

func (t *TenantUseCase) FindByIdOrName(ctx context.Context, idOrName string) (*Tenant, error)

func (*TenantUseCase) First

func (t *TenantUseCase) First(ctx context.Context, query *v1.ListTenantRequest) (*Tenant, error)

func (*TenantUseCase) Get

func (t *TenantUseCase) Get(ctx context.Context, id string) (*Tenant, error)

func (*TenantUseCase) List

func (t *TenantUseCase) List(ctx context.Context, query *v1.ListTenantRequest) ([]*Tenant, error)

func (*TenantUseCase) Update

func (t *TenantUseCase) Update(ctx context.Context, entity *Tenant, p query.Select) error

Jump to

Keyboard shortcuts

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