mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools
Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
* GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
* GET /api/v1/users/me/organizations - User organizations
* POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue
API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules
Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
79 lines
2.5 KiB
Go
79 lines
2.5 KiB
Go
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
|
|
}
|