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)
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"bugulma/backend/internal/domain"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// SharedAssetRepository implements domain.SharedAssetRepository with GORM
|
|
type SharedAssetRepository struct {
|
|
*BaseRepository[domain.SharedAsset]
|
|
}
|
|
|
|
// NewSharedAssetRepository creates a new GORM-based shared asset repository
|
|
func NewSharedAssetRepository(db *gorm.DB) domain.SharedAssetRepository {
|
|
return &SharedAssetRepository{
|
|
BaseRepository: NewBaseRepository[domain.SharedAsset](db),
|
|
}
|
|
}
|
|
|
|
// GetBySiteID retrieves shared assets at a specific site
|
|
func (r *SharedAssetRepository) GetBySiteID(ctx context.Context, siteID string) ([]*domain.SharedAsset, error) {
|
|
return r.FindWhereWithContext(ctx, "site_id = ?", siteID)
|
|
}
|
|
|
|
// GetByOwnerID retrieves shared assets owned by a specific organization
|
|
func (r *SharedAssetRepository) GetByOwnerID(ctx context.Context, ownerID string) ([]*domain.SharedAsset, error) {
|
|
return r.FindWhereWithContext(ctx, "owner_organization_id = ?", ownerID)
|
|
}
|
|
|
|
// GetByType retrieves shared assets by type
|
|
func (r *SharedAssetRepository) GetByType(ctx context.Context, assetType domain.AssetType) ([]*domain.SharedAsset, error) {
|
|
return r.FindWhereWithContext(ctx, "type = ?", assetType)
|
|
}
|
|
|
|
// GetAvailable retrieves assets with available capacity (utilization < 1.0)
|
|
func (r *SharedAssetRepository) GetAvailable(ctx context.Context) ([]*domain.SharedAsset, error) {
|
|
return r.FindWhereWithContext(ctx, "utilization_rate < ? AND operational_status = ?", 1.0, domain.StatusOperational)
|
|
}
|