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
32 lines
971 B
Go
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)
|
|
}
|