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)
72 lines
2.6 KiB
Go
72 lines
2.6 KiB
Go
package domain
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// UrgencyLevel defines the urgency of a service need
|
|
type UrgencyLevel string
|
|
|
|
const (
|
|
UrgencyLow UrgencyLevel = "low"
|
|
UrgencyMedium UrgencyLevel = "medium"
|
|
UrgencyHigh UrgencyLevel = "high"
|
|
)
|
|
|
|
// ServiceNeed represents a service needed by an organization (database entity)
|
|
// Note: There's also a ServiceNeedJSON struct in organization.go for API serialization
|
|
type ServiceNeed struct {
|
|
ID string `gorm:"primaryKey;type:text"`
|
|
Type string `gorm:"not null;type:text;index"` // Type of service needed
|
|
Description string `gorm:"type:text"`
|
|
Urgency UrgencyLevel `gorm:"type:varchar(20);default:'medium'"`
|
|
Budget float64 `gorm:"type:decimal(10,2)"` // Available budget in €
|
|
PreferredProviders datatypes.JSON `gorm:"type:jsonb;default:'[]'"` // []string - Organization IDs
|
|
|
|
// Business information
|
|
OrganizationID string `gorm:"not null;type:text;index"`
|
|
Organization *Organization `gorm:"foreignKey:OrganizationID"`
|
|
|
|
// Additional metadata
|
|
Requirements datatypes.JSON `gorm:"type:jsonb;default:'{}'"` // Specific requirements
|
|
Timeframe string `gorm:"type:text"` // When service is needed
|
|
Status string `gorm:"type:varchar(50);default:'active'"` // active, fulfilled, cancelled
|
|
Sources datatypes.JSON `gorm:"type:jsonb"` // Data sources
|
|
|
|
// Timestamps
|
|
CreatedAt time.Time `gorm:"autoCreateTime"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
|
}
|
|
|
|
// TableName specifies the table name for GORM
|
|
func (ServiceNeed) TableName() string {
|
|
return "service_needs"
|
|
}
|
|
|
|
// ServiceNeedRepository defines operations for service need management
|
|
type ServiceNeedRepository interface {
|
|
Create(ctx context.Context, serviceNeed *ServiceNeed) error
|
|
GetByID(ctx context.Context, id string) (*ServiceNeed, error)
|
|
GetByOrganization(ctx context.Context, organizationID string) ([]*ServiceNeed, error)
|
|
GetByType(ctx context.Context, serviceType string) ([]*ServiceNeed, error)
|
|
GetByUrgency(ctx context.Context, urgency UrgencyLevel) ([]*ServiceNeed, error)
|
|
GetActiveNeeds(ctx context.Context) ([]*ServiceNeed, error)
|
|
Update(ctx context.Context, serviceNeed *ServiceNeed) error
|
|
Delete(ctx context.Context, id string) error
|
|
}
|
|
|
|
// Validate performs business rule validation
|
|
func (sn *ServiceNeed) Validate() error {
|
|
if sn.Type == "" {
|
|
return fmt.Errorf("service type cannot be empty")
|
|
}
|
|
if sn.Budget < 0 {
|
|
return fmt.Errorf("budget cannot be negative")
|
|
}
|
|
return nil
|
|
}
|