tenant

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceTypeTenant = "tenant"

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQLRepository

type MySQLRepository struct {
	database.SQLRepository
}

func NewMySQLRepository

func NewMySQLRepository(db *database.MySQL) MySQLRepository

func (MySQLRepository) Create

func (repo MySQLRepository) Create(ctx context.Context, tenant Tenant) (int64, error)

func (MySQLRepository) DeleteByTenantId

func (repo MySQLRepository) DeleteByTenantId(ctx context.Context, tenantId string) error

func (MySQLRepository) GetById

func (repo MySQLRepository) GetById(ctx context.Context, id int64) (*Tenant, error)

func (MySQLRepository) GetByTenantId

func (repo MySQLRepository) GetByTenantId(ctx context.Context, tenantId string) (*Tenant, error)

func (MySQLRepository) List

func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Tenant, error)

func (MySQLRepository) UpdateByTenantId

func (repo MySQLRepository) UpdateByTenantId(ctx context.Context, tenantId string, tenant Tenant) error

type PostgresRepository added in v0.4.0

type PostgresRepository struct {
	database.SQLRepository
}

func NewPostgresRepository added in v0.4.0

func NewPostgresRepository(db *database.Postgres) PostgresRepository

func (PostgresRepository) Create added in v0.4.0

func (repo PostgresRepository) Create(ctx context.Context, tenant Tenant) (int64, error)

func (PostgresRepository) DeleteByTenantId added in v0.4.0

func (repo PostgresRepository) DeleteByTenantId(ctx context.Context, tenantId string) error

func (PostgresRepository) GetById added in v0.4.0

func (repo PostgresRepository) GetById(ctx context.Context, id int64) (*Tenant, error)

func (PostgresRepository) GetByTenantId added in v0.4.0

func (repo PostgresRepository) GetByTenantId(ctx context.Context, tenantId string) (*Tenant, error)

func (PostgresRepository) List added in v0.4.0

func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Tenant, error)

func (PostgresRepository) UpdateByTenantId added in v0.4.0

func (repo PostgresRepository) UpdateByTenantId(ctx context.Context, tenantId string, tenant Tenant) error

type Tenant

type Tenant struct {
	ID        int64               `mysql:"id" postgres:"id"`
	ObjectId  int64               `mysql:"objectId" postgres:"object_id"`
	TenantId  string              `mysql:"tenantId" postgres:"tenant_id"`
	Name      database.NullString `mysql:"name" postgres:"name"`
	CreatedAt time.Time           `mysql:"createdAt" postgres:"created_at"`
	UpdatedAt time.Time           `mysql:"updatedAt" postgres:"updated_at"`
	DeletedAt database.NullTime   `mysql:"deletedAt" postgres:"deleted_at"`
}

Tenant model

func (Tenant) ToTenantSpec

func (tenant Tenant) ToTenantSpec() *TenantSpec

type TenantListParamParser

type TenantListParamParser struct{}

func (TenantListParamParser) GetDefaultSortBy

func (parser TenantListParamParser) GetDefaultSortBy() string

func (TenantListParamParser) GetSupportedSortBys

func (parser TenantListParamParser) GetSupportedSortBys() []string

func (TenantListParamParser) ParseValue

func (parser TenantListParamParser) ParseValue(val string, sortBy string) (interface{}, error)

type TenantRepository

type TenantRepository interface {
	Create(ctx context.Context, tenant Tenant) (int64, error)
	GetById(ctx context.Context, id int64) (*Tenant, error)
	GetByTenantId(ctx context.Context, tenantId string) (*Tenant, error)
	List(ctx context.Context, listParams middleware.ListParams) ([]Tenant, error)
	UpdateByTenantId(ctx context.Context, tenantId string, tenant Tenant) error
	DeleteByTenantId(ctx context.Context, tenantId string) error
}

func NewRepository

func NewRepository(db database.Database) (TenantRepository, error)

type TenantService

type TenantService struct {
	service.BaseService
}

func NewService

func NewService(env service.Env) TenantService

func (TenantService) Create

func (svc TenantService) Create(ctx context.Context, tenantSpec TenantSpec) (*TenantSpec, error)

func (TenantService) DeleteByTenantId

func (svc TenantService) DeleteByTenantId(ctx context.Context, tenantId string) error

func (TenantService) GetByTenantId

func (svc TenantService) GetByTenantId(ctx context.Context, tenantId string) (*TenantSpec, error)

func (TenantService) GetRoutes

func (svc TenantService) GetRoutes() []service.Route

GetRoutes registers all route handlers for this module

func (TenantService) List

func (svc TenantService) List(ctx context.Context, listParams middleware.ListParams) ([]TenantSpec, error)

func (TenantService) UpdateByTenantId

func (svc TenantService) UpdateByTenantId(ctx context.Context, tenantId string, tenantSpec UpdateTenantSpec) (*TenantSpec, error)

type TenantSpec

type TenantSpec struct {
	TenantId  string              `json:"tenantId"`
	Name      database.NullString `json:"name"`
	CreatedAt time.Time           `json:"createdAt"`
}

func (TenantSpec) ToObjectSpec

func (spec TenantSpec) ToObjectSpec() *object.ObjectSpec

func (TenantSpec) ToTenant

func (spec TenantSpec) ToTenant(objectId int64) *Tenant

type UpdateTenantSpec

type UpdateTenantSpec struct {
	Name database.NullString `json:"name"`
}

Jump to

Keyboard shortcuts

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