gohorsejobs/backend/internal/services/location_service.go
Tiago Yamamoto fb79e987bb feat: add location selector and contract types
Backend:
- Created LocationHandler, LocationService, LocationRepository
- Added endpoints: GET /api/v1/locations/countries, states, cities, search
- Added migration 029_expand_employment_types.sql with new contract types (permanent, training, temporary, voluntary)
- Fixed .gitignore to allow internal/api folder

Frontend:
- Created LocationPicker component with country dropdown and city/state autocomplete search
- Integrated LocationPicker into PostJobPage
- Updated contract type options in job form (Permanent, Contract, Training, Temporary, Voluntary)
- Added locationsApi with search functionality to api.ts
2025-12-26 15:18:16 -03:00

32 lines
971 B
Go

package services
import (
"context"
"github.com/rede5/gohorsejobs/backend/internal/core/domain/entity"
"github.com/rede5/gohorsejobs/backend/internal/infrastructure/persistence/postgres"
)
type LocationService struct {
repo *postgres.LocationRepository
}
func NewLocationService(repo *postgres.LocationRepository) *LocationService {
return &LocationService{repo: repo}
}
func (s *LocationService) ListCountries(ctx context.Context) ([]*entity.Country, error) {
return s.repo.ListCountries(ctx)
}
func (s *LocationService) ListStates(ctx context.Context, countryID int64) ([]*entity.State, error) {
return s.repo.ListStates(ctx, countryID)
}
func (s *LocationService) ListCities(ctx context.Context, stateID int64) ([]*entity.City, error) {
return s.repo.ListCities(ctx, stateID)
}
func (s *LocationService) Search(ctx context.Context, query string, countryID int64) ([]*entity.LocationSearchResult, error) {
return s.repo.Search(ctx, query, countryID)
}