package domain import ( "context" "time" "gorm.io/datatypes" ) // AssetType represents the type of shared asset type AssetType string const ( AssetTypeInfrastructure AssetType = "infrastructure" AssetTypeUtilities AssetType = "utilities" AssetTypeEquipment AssetType = "equipment" AssetTypeSpace AssetType = "space" ) // OperationalStatus represents the current operational status of an asset type OperationalStatus string const ( StatusOperational OperationalStatus = "operational" StatusMaintenance OperationalStatus = "maintenance" StatusOutOfService OperationalStatus = "out_of_service" ) // SharedAsset represents equipment/infrastructure at specific sites that can be shared among businesses type SharedAsset struct { ID string `gorm:"primaryKey;type:text"` SiteID string `gorm:"type:text;not null;index"` OwnerBusinessID string `gorm:"type:text;not null;index"` // Asset details Type AssetType `gorm:"type:varchar(50);not null;index"` Description string `gorm:"type:text"` // Capacity Capacity float64 `gorm:"type:double precision"` CapacityUnit string `gorm:"type:varchar(50)"` // Utilization UtilizationRate float64 `gorm:"type:double precision;check:utilization_rate BETWEEN 0 AND 1"` AvailabilityPeriod string `gorm:"type:varchar(255)"` // Sharing CostSharingModel string `gorm:"type:varchar(255)"` CurrentUsers datatypes.JSON `gorm:"default:'[]'"` // []string - Organization IDs // Maintenance MaintenanceSchedule string `gorm:"type:text"` OperationalStatus OperationalStatus `gorm:"type:varchar(50);default:'operational'"` // Timestamps CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"` // Associations Site *Site `gorm:"foreignKey:SiteID"` OwnerBusiness *Organization `gorm:"foreignKey:OwnerBusinessID"` } // TableName specifies the table name for GORM func (SharedAsset) TableName() string { return "shared_assets" } type SharedAssetRepository interface { Create(ctx context.Context, asset *SharedAsset) error GetByID(ctx context.Context, id string) (*SharedAsset, error) GetBySiteID(ctx context.Context, siteID string) ([]*SharedAsset, error) GetByOwnerID(ctx context.Context, ownerID string) ([]*SharedAsset, error) GetByType(ctx context.Context, assetType AssetType) ([]*SharedAsset, error) GetAvailable(ctx context.Context) ([]*SharedAsset, error) // Assets with utilization < 1.0 Update(ctx context.Context, asset *SharedAsset) error Delete(ctx context.Context, id string) error }