aurganize-backend/backend/internal/models/tenants.go

83 lines
3.1 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
)
type Tenant struct {
ID uuid.UUID `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Slug string `json:"slug" db:"slug"`
Email *string `json:"email" db:"email"`
Phone *string `json:"phone" db:"phone"`
Website *string `json:"website" db:"website"`
AddressLine1 *string `json:"address_line1" db:"address_line1"`
AddressLine2 *string `json:"address_line2" db:"address_line2"`
City *string `json:"city" db:"city"`
State *string `json:"state" db:"state"`
Country *string `json:"country" db:"country"`
PostalCode *string `json:"postal_code" db:"postal_code"`
Timezone string `json:"timezone" db:"timezone"`
Currency string `json:"currency" db:"currency"`
Locale string `json:"locale" db:"locale"`
SubscriptionStatus string `json:"subscription_status" db:"subscription_status"`
SubscriptionPlan string `json:"subscription_plan" db:"subscription_plan"`
SubscriptionExpiresAt *time.Time `json:"subscription_expires_at" db:"subscription_expires_at"`
TrialEnds *time.Time `json:"trial_ends_at" db:"trial_ends_at"`
MaxUsers int `json:"max_users" db:"max_users"`
MaxContracts int `json:"max_contracts" db:"max_contracts"`
MaxStorageMB int `json:"max_storage_mb" db:"max_storage_mb"`
Status string `json:"status" db:"status"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt *time.Time `json:"updated_at" db:"updated_at"`
DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
}
type CreateTenantInput struct {
Name string
Email *string
Timezone string
Currency string
Locale string
}
type CreateTenantWithUserInput struct {
TenantName string
Email *string
Password *string
FirstName *string
LastName *string
}
type TenantResponse struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Email *string `json:"email"`
Timezone string `json:"timezone"`
Currency string `json:"currency"`
SubscriptionStatus string `json:"subscription_status"`
SubscriptionPlan string `json:"subscription_plan"`
TrialEnds *time.Time `json:"trial_ends_at"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
}
func (t *Tenant) ToResponse() *TenantResponse {
return &TenantResponse{
ID: t.ID,
Name: t.Name,
Slug: t.Slug,
Email: t.Email,
Timezone: t.Timezone,
Currency: t.Currency,
SubscriptionStatus: t.SubscriptionStatus,
SubscriptionPlan: t.SubscriptionPlan,
TrialEnds: t.TrialEnds,
Status: t.Status,
CreatedAt: t.CreatedAt,
}
}