tenant

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSortBy = "tenantId"
View Source
const ResourceTypeTenant = "tenant"

Variables

This section is empty.

Functions

func CreateHandler added in v0.11.0

func CreateHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error

func DeleteHandler added in v0.11.0

func DeleteHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error

func GetHandler added in v0.11.0

func GetHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error

func ListHandler added in v0.11.0

func ListHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error

func UpdateHandler added in v0.11.0

func UpdateHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error

Types

type Model added in v0.8.0

type Model interface {
	GetID() int64
	GetObjectId() int64
	GetTenantId() string
	GetName() *string
	SetName(newName *string)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() *time.Time
	ToTenantSpec() *TenantSpec
}

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, model Model) (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) (Model, error)

func (MySQLRepository) GetByTenantId

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

func (MySQLRepository) List

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

func (MySQLRepository) UpdateByTenantId

func (repo MySQLRepository) UpdateByTenantId(ctx context.Context, tenantId string, model Model) 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, model Model) (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) (Model, error)

func (PostgresRepository) GetByTenantId added in v0.4.0

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

func (PostgresRepository) List added in v0.4.0

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

func (PostgresRepository) UpdateByTenantId added in v0.4.0

func (repo PostgresRepository) UpdateByTenantId(ctx context.Context, tenantId string, model Model) error

type SQLiteRepository added in v0.11.0

type SQLiteRepository struct {
	database.SQLRepository
}

func NewSQLiteRepository added in v0.11.0

func NewSQLiteRepository(db *database.SQLite) *SQLiteRepository

func (SQLiteRepository) Create added in v0.11.0

func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)

func (SQLiteRepository) DeleteByTenantId added in v0.11.0

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

func (SQLiteRepository) GetById added in v0.11.0

func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)

func (SQLiteRepository) GetByTenantId added in v0.11.0

func (repo SQLiteRepository) GetByTenantId(ctx context.Context, tenantId string) (Model, error)

func (SQLiteRepository) List added in v0.11.0

func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)

func (SQLiteRepository) UpdateByTenantId added in v0.11.0

func (repo SQLiteRepository) UpdateByTenantId(ctx context.Context, tenantId string, model Model) error

type Tenant

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

func (Tenant) GetCreatedAt added in v0.8.0

func (tenant Tenant) GetCreatedAt() time.Time

func (Tenant) GetDeletedAt added in v0.8.0

func (tenant Tenant) GetDeletedAt() *time.Time

func (Tenant) GetID added in v0.8.0

func (tenant Tenant) GetID() int64

func (Tenant) GetName added in v0.8.0

func (tenant Tenant) GetName() *string

func (Tenant) GetObjectId added in v0.8.0

func (tenant Tenant) GetObjectId() int64

func (Tenant) GetTenantId added in v0.8.0

func (tenant Tenant) GetTenantId() string

func (Tenant) GetUpdatedAt added in v0.8.0

func (tenant Tenant) GetUpdatedAt() time.Time

func (*Tenant) SetName added in v0.8.0

func (tenant *Tenant) SetName(newName *string)

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 Model) (int64, error)
	GetById(ctx context.Context, id int64) (Model, error)
	GetByTenantId(ctx context.Context, tenantId string) (Model, error)
	List(ctx context.Context, listParams service.ListParams) ([]Model, error)
	UpdateByTenantId(ctx context.Context, tenantId string, tenant Model) error
	DeleteByTenantId(ctx context.Context, tenantId string) error
}

func NewRepository

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

type TenantService

type TenantService struct {
	service.BaseService
	Repository TenantRepository
	EventSvc   event.Service
	ObjectSvc  *object.ObjectService
}

func NewService

func NewService(env service.Env, repository TenantRepository, eventSvc event.Service, objectSvc *object.ObjectService) *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) (*wookie.Token, error)

func (TenantService) GetByTenantId

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

func (TenantService) List

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

func (TenantService) Routes added in v0.8.0

func (svc TenantService) Routes() ([]service.Route, error)

GetRoutes registers all route handlers for this module

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" validate:"omitempty,valid_object_id"`
	Name      *string   `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 *string `json:"name"`
}

Jump to

Keyboard shortcuts

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