Documentation
¶
Index ¶
- Constants
- func CreateHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error
- func DeleteHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error
- func GetHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error
- func ListHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error
- func UpdateHandler(svc TenantService, w http.ResponseWriter, r *http.Request) error
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByTenantId(ctx context.Context, tenantId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByTenantId(ctx context.Context, tenantId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
- func (repo MySQLRepository) UpdateByTenantId(ctx context.Context, tenantId string, model Model) error
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByTenantId(ctx context.Context, tenantId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByTenantId(ctx context.Context, tenantId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
- func (repo PostgresRepository) UpdateByTenantId(ctx context.Context, tenantId string, model Model) error
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByTenantId(ctx context.Context, tenantId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByTenantId(ctx context.Context, tenantId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
- func (repo SQLiteRepository) UpdateByTenantId(ctx context.Context, tenantId string, model Model) error
- type Tenant
- func (tenant Tenant) GetCreatedAt() time.Time
- func (tenant Tenant) GetDeletedAt() *time.Time
- func (tenant Tenant) GetID() int64
- func (tenant Tenant) GetName() *string
- func (tenant Tenant) GetObjectId() int64
- func (tenant Tenant) GetTenantId() string
- func (tenant Tenant) GetUpdatedAt() time.Time
- func (tenant *Tenant) SetName(newName *string)
- func (tenant Tenant) ToTenantSpec() *TenantSpec
- type TenantListParamParser
- type TenantRepository
- type TenantService
- func (svc TenantService) Create(ctx context.Context, tenantSpec TenantSpec) (*TenantSpec, error)
- func (svc TenantService) DeleteByTenantId(ctx context.Context, tenantId string) error
- func (svc TenantService) GetByTenantId(ctx context.Context, tenantId string) (*TenantSpec, error)
- func (svc TenantService) List(ctx context.Context, listParams middleware.ListParams) ([]TenantSpec, error)
- func (svc TenantService) Routes() ([]service.Route, error)
- func (svc TenantService) UpdateByTenantId(ctx context.Context, tenantId string, tenantSpec UpdateTenantSpec) (*TenantSpec, error)
- type TenantSpec
- type UpdateTenantSpec
Constants ¶
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 MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteByTenantId ¶
func (repo MySQLRepository) DeleteByTenantId(ctx context.Context, tenantId string) error
func (MySQLRepository) GetByTenantId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
func (MySQLRepository) UpdateByTenantId ¶
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) DeleteByTenantId ¶ added in v0.4.0
func (repo PostgresRepository) DeleteByTenantId(ctx context.Context, tenantId string) error
func (PostgresRepository) GetByTenantId ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
func (PostgresRepository) UpdateByTenantId ¶ added in v0.4.0
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) DeleteByTenantId ¶ added in v0.11.0
func (repo SQLiteRepository) DeleteByTenantId(ctx context.Context, tenantId string) error
func (SQLiteRepository) GetByTenantId ¶ added in v0.11.0
func (SQLiteRepository) List ¶ added in v0.11.0
func (repo SQLiteRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Model, error)
func (SQLiteRepository) UpdateByTenantId ¶ added in v0.11.0
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) GetDeletedAt ¶ added in v0.8.0
func (Tenant) GetObjectId ¶ added in v0.8.0
func (Tenant) GetTenantId ¶ added in v0.8.0
func (Tenant) GetUpdatedAt ¶ added in v0.8.0
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 middleware.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.EventService
ObjectSvc object.ObjectService
}
func NewService ¶
func NewService(env service.Env, repository TenantRepository, eventSvc event.EventService, 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) 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 middleware.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"`
}
Click to show internal directories.
Click to hide internal directories.