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
|
|
@ -0,0 +1,61 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/domain/tenant"
|
||||
)
|
||||
|
||||
// TenantByID represents the tenants_by_id table
|
||||
// Query pattern: Get tenant by ID
|
||||
// Primary key: id
|
||||
type TenantByID struct {
|
||||
ID string `db:"id"`
|
||||
Name string `db:"name"`
|
||||
Slug string `db:"slug"`
|
||||
Status string `db:"status"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
|
||||
// CWE-359: IP address tracking for GDPR compliance
|
||||
CreatedFromIPAddress string `db:"created_from_ip_address"`
|
||||
CreatedFromIPTimestamp time.Time `db:"created_from_ip_timestamp"`
|
||||
ModifiedFromIPAddress string `db:"modified_from_ip_address"`
|
||||
ModifiedFromIPTimestamp time.Time `db:"modified_from_ip_timestamp"`
|
||||
}
|
||||
|
||||
// ToTenant converts table model to domain entity
|
||||
func (t *TenantByID) ToTenant() *tenant.Tenant {
|
||||
return &tenant.Tenant{
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Slug: t.Slug,
|
||||
Status: tenant.Status(t.Status),
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
|
||||
// CWE-359: IP address tracking
|
||||
CreatedFromIPAddress: t.CreatedFromIPAddress,
|
||||
CreatedFromIPTimestamp: t.CreatedFromIPTimestamp,
|
||||
ModifiedFromIPAddress: t.ModifiedFromIPAddress,
|
||||
ModifiedFromIPTimestamp: t.ModifiedFromIPTimestamp,
|
||||
}
|
||||
}
|
||||
|
||||
// FromTenant converts domain entity to table model
|
||||
func FromTenant(t *tenant.Tenant) *TenantByID {
|
||||
return &TenantByID{
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Slug: t.Slug,
|
||||
Status: string(t.Status),
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
|
||||
// CWE-359: IP address tracking
|
||||
CreatedFromIPAddress: t.CreatedFromIPAddress,
|
||||
CreatedFromIPTimestamp: t.CreatedFromIPTimestamp,
|
||||
ModifiedFromIPAddress: t.ModifiedFromIPAddress,
|
||||
ModifiedFromIPTimestamp: t.ModifiedFromIPTimestamp,
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/domain/tenant"
|
||||
)
|
||||
|
||||
// TenantBySlug represents the tenants_by_slug table
|
||||
// Query pattern: Get tenant by slug (URL-friendly identifier)
|
||||
// Primary key: slug
|
||||
type TenantBySlug struct {
|
||||
Slug string `db:"slug"`
|
||||
ID string `db:"id"`
|
||||
Name string `db:"name"`
|
||||
Status string `db:"status"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
|
||||
// CWE-359: IP address tracking for GDPR compliance
|
||||
CreatedFromIPAddress string `db:"created_from_ip_address"`
|
||||
CreatedFromIPTimestamp time.Time `db:"created_from_ip_timestamp"`
|
||||
ModifiedFromIPAddress string `db:"modified_from_ip_address"`
|
||||
ModifiedFromIPTimestamp time.Time `db:"modified_from_ip_timestamp"`
|
||||
}
|
||||
|
||||
// ToTenant converts table model to domain entity
|
||||
func (t *TenantBySlug) ToTenant() *tenant.Tenant {
|
||||
return &tenant.Tenant{
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Slug: t.Slug,
|
||||
Status: tenant.Status(t.Status),
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
|
||||
// CWE-359: IP address tracking
|
||||
CreatedFromIPAddress: t.CreatedFromIPAddress,
|
||||
CreatedFromIPTimestamp: t.CreatedFromIPTimestamp,
|
||||
ModifiedFromIPAddress: t.ModifiedFromIPAddress,
|
||||
ModifiedFromIPTimestamp: t.ModifiedFromIPTimestamp,
|
||||
}
|
||||
}
|
||||
|
||||
// FromTenantBySlug converts domain entity to table model
|
||||
func FromTenantBySlug(t *tenant.Tenant) *TenantBySlug {
|
||||
return &TenantBySlug{
|
||||
Slug: t.Slug,
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Status: string(t.Status),
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
|
||||
// CWE-359: IP address tracking
|
||||
CreatedFromIPAddress: t.CreatedFromIPAddress,
|
||||
CreatedFromIPTimestamp: t.CreatedFromIPTimestamp,
|
||||
ModifiedFromIPAddress: t.ModifiedFromIPAddress,
|
||||
ModifiedFromIPTimestamp: t.ModifiedFromIPTimestamp,
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/domain/tenant"
|
||||
)
|
||||
|
||||
// TenantByStatus represents the tenants_by_status table
|
||||
// Query pattern: List tenants by status (e.g., active, inactive, suspended)
|
||||
// Primary key: (status, id) - status is partition key, id is clustering key
|
||||
type TenantByStatus struct {
|
||||
Status string `db:"status"`
|
||||
ID string `db:"id"`
|
||||
Name string `db:"name"`
|
||||
Slug string `db:"slug"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
|
||||
// CWE-359: IP address tracking for GDPR compliance
|
||||
CreatedFromIPAddress string `db:"created_from_ip_address"`
|
||||
CreatedFromIPTimestamp time.Time `db:"created_from_ip_timestamp"`
|
||||
ModifiedFromIPAddress string `db:"modified_from_ip_address"`
|
||||
ModifiedFromIPTimestamp time.Time `db:"modified_from_ip_timestamp"`
|
||||
}
|
||||
|
||||
// ToTenant converts table model to domain entity
|
||||
func (t *TenantByStatus) ToTenant() *tenant.Tenant {
|
||||
return &tenant.Tenant{
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Slug: t.Slug,
|
||||
Status: tenant.Status(t.Status),
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
|
||||
// CWE-359: IP address tracking
|
||||
CreatedFromIPAddress: t.CreatedFromIPAddress,
|
||||
CreatedFromIPTimestamp: t.CreatedFromIPTimestamp,
|
||||
ModifiedFromIPAddress: t.ModifiedFromIPAddress,
|
||||
ModifiedFromIPTimestamp: t.ModifiedFromIPTimestamp,
|
||||
}
|
||||
}
|
||||
|
||||
// FromTenantByStatus converts domain entity to table model
|
||||
func FromTenantByStatus(t *tenant.Tenant) *TenantByStatus {
|
||||
return &TenantByStatus{
|
||||
Status: string(t.Status),
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Slug: t.Slug,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
|
||||
// CWE-359: IP address tracking
|
||||
CreatedFromIPAddress: t.CreatedFromIPAddress,
|
||||
CreatedFromIPTimestamp: t.CreatedFromIPTimestamp,
|
||||
ModifiedFromIPAddress: t.ModifiedFromIPAddress,
|
||||
ModifiedFromIPTimestamp: t.ModifiedFromIPTimestamp,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue