Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
72
cloud/maplepress-backend/internal/usecase/tenant/get.go
Normal file
72
cloud/maplepress-backend/internal/usecase/tenant/get.go
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
package tenant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
domaintenant "codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/domain/tenant"
|
||||
)
|
||||
|
||||
// GetTenantInput represents the input for getting a tenant
|
||||
type GetTenantInput struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
// GetTenantBySlugInput represents the input for getting a tenant by slug
|
||||
type GetTenantBySlugInput struct {
|
||||
Slug string
|
||||
}
|
||||
|
||||
// GetTenantOutput represents the output after getting a tenant
|
||||
type GetTenantOutput struct {
|
||||
ID string
|
||||
Name string
|
||||
Slug string
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// GetTenantUseCase handles tenant retrieval business logic
|
||||
type GetTenantUseCase struct {
|
||||
repo domaintenant.Repository
|
||||
}
|
||||
|
||||
// ProvideGetTenantUseCase creates a new GetTenantUseCase
|
||||
func ProvideGetTenantUseCase(repo domaintenant.Repository) *GetTenantUseCase {
|
||||
return &GetTenantUseCase{repo: repo}
|
||||
}
|
||||
|
||||
// Execute retrieves a tenant by ID
|
||||
func (uc *GetTenantUseCase) Execute(ctx context.Context, input *GetTenantInput) (*GetTenantOutput, error) {
|
||||
tenant, err := uc.repo.GetByID(ctx, input.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &GetTenantOutput{
|
||||
ID: tenant.ID,
|
||||
Name: tenant.Name,
|
||||
Slug: tenant.Slug,
|
||||
Status: string(tenant.Status),
|
||||
CreatedAt: tenant.CreatedAt,
|
||||
UpdatedAt: tenant.UpdatedAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ExecuteBySlug retrieves a tenant by slug
|
||||
func (uc *GetTenantUseCase) ExecuteBySlug(ctx context.Context, input *GetTenantBySlugInput) (*GetTenantOutput, error) {
|
||||
tenant, err := uc.repo.GetBySlug(ctx, input.Slug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &GetTenantOutput{
|
||||
ID: tenant.ID,
|
||||
Name: tenant.Name,
|
||||
Slug: tenant.Slug,
|
||||
Status: string(tenant.Status),
|
||||
CreatedAt: tenant.CreatedAt,
|
||||
UpdatedAt: tenant.UpdatedAt,
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue