140 lines
4.4 KiB
Go
140 lines
4.4 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"github.com/dnoulet/go-first/internal/model"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type ServiceService struct {
|
|
mu sync.RWMutex
|
|
services map[uuid.UUID]*model.Service
|
|
}
|
|
|
|
func NewServiceService() *ServiceService {
|
|
s := &ServiceService{
|
|
services: make(map[uuid.UUID]*model.Service),
|
|
}
|
|
s.seedData()
|
|
return s
|
|
}
|
|
|
|
func (s *ServiceService) seedData() {
|
|
services := []*model.Service{
|
|
{
|
|
ID: uuid.New(),
|
|
Title: "Web Application Development",
|
|
Description: "Custom web applications built with modern technologies. From concept to deployment, we deliver scalable, maintainable solutions tailored to your business needs.",
|
|
Icon: "code",
|
|
Features: []string{"React/Next.js Frontend", "Go/Java Backend", "REST/GraphQL APIs", "Real-time Features", "Progressive Web Apps", "TypeScript"},
|
|
Order: 1,
|
|
Active: true,
|
|
},
|
|
{
|
|
ID: uuid.New(),
|
|
Title: "Backend & API Development",
|
|
Description: "Robust backend systems and APIs designed for scale. Microservices, event-driven architectures, and high-performance systems that power your business logic.",
|
|
Icon: "server",
|
|
Features: []string{"Microservices Architecture", "REST & GraphQL APIs", "gRPC Services", "Event-Driven Systems", "Database Design", "Caching Strategies"},
|
|
Order: 2,
|
|
Active: true,
|
|
},
|
|
{
|
|
ID: uuid.New(),
|
|
Title: "Cloud Infrastructure & DevOps",
|
|
Description: "End-to-end infrastructure solutions on AWS, GCP, or Azure. Container orchestration, CI/CD pipelines, monitoring, and infrastructure as code.",
|
|
Icon: "cloud",
|
|
Features: []string{"Kubernetes & Docker", "AWS/GCP/Azure", "Terraform/IaC", "CI/CD Pipelines", "Monitoring & Logging", "Security Hardening"},
|
|
Order: 3,
|
|
Active: true,
|
|
},
|
|
{
|
|
ID: uuid.New(),
|
|
Title: "System Architecture & Consulting",
|
|
Description: "Expert architectural guidance for complex systems. Technology selection, scalability planning, performance optimization, and technical debt reduction.",
|
|
Icon: "architecture",
|
|
Features: []string{"System Design Reviews", "Technology Evaluation", "Scalability Planning", "Performance Optimization", "Migration Strategies", "Code Audits"},
|
|
Order: 4,
|
|
Active: true,
|
|
},
|
|
{
|
|
ID: uuid.New(),
|
|
Title: "Legacy Modernization",
|
|
Description: "Transform legacy systems into modern, maintainable applications. Strangler fig pattern, domain-driven design, and incremental migration strategies.",
|
|
Icon: "refresh",
|
|
Features: []string{"Legacy Assessment", "Strangler Fig Migration", "Domain-Driven Design", "Data Migration", "API Facade Pattern", "Automated Testing"},
|
|
Order: 5,
|
|
Active: true,
|
|
},
|
|
{
|
|
ID: uuid.New(),
|
|
Title: "Technical Advisory & CTO Services",
|
|
Description: "Fractional CTO and technical advisory services for startups and scale-ups. Technology strategy, team building, and technical roadmap planning.",
|
|
Icon: "advisor",
|
|
Features: []string{"Technology Strategy", "Team Building & Hiring", "Technical Roadmaps", "Vendor Evaluation", "Architecture Decisions", "Investor Technical Due Diligence"},
|
|
Order: 6,
|
|
Active: true,
|
|
},
|
|
}
|
|
|
|
for _, svc := range services {
|
|
s.services[svc.ID] = svc
|
|
}
|
|
}
|
|
|
|
func (s *ServiceService) GetAll(ctx context.Context) ([]*model.Service, error) {
|
|
s.mu.RLock()
|
|
defer s.mu.RUnlock()
|
|
|
|
var result []*model.Service
|
|
for _, svc := range s.services {
|
|
if svc.Active {
|
|
result = append(result, svc)
|
|
}
|
|
}
|
|
return result, nil
|
|
}
|
|
|
|
func (s *ServiceService) GetByID(ctx context.Context, id uuid.UUID) (*model.Service, error) {
|
|
s.mu.RLock()
|
|
defer s.mu.RUnlock()
|
|
|
|
svc, ok := s.services[id]
|
|
if !ok {
|
|
return nil, ErrNotFound
|
|
}
|
|
return svc, nil
|
|
}
|
|
|
|
func (s *ServiceService) Create(ctx context.Context, svc *model.Service) (*model.Service, error) {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
|
|
svc.ID = uuid.New()
|
|
s.services[svc.ID] = svc
|
|
return svc, nil
|
|
}
|
|
|
|
func (s *ServiceService) Update(ctx context.Context, svc *model.Service) (*model.Service, error) {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
|
|
if _, ok := s.services[svc.ID]; !ok {
|
|
return nil, ErrNotFound
|
|
}
|
|
s.services[svc.ID] = svc
|
|
return svc, nil
|
|
}
|
|
|
|
func (s *ServiceService) Delete(ctx context.Context, id uuid.UUID) error {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
|
|
if _, ok := s.services[id]; !ok {
|
|
return ErrNotFound
|
|
}
|
|
delete(s.services, id)
|
|
return nil
|
|
}
|