Files
s01e02/internal/domain/report.go
2026-03-12 02:10:57 +01:00

33 lines
963 B
Go

package domain
import "sort"
// PersonWithDistance represents a person with their distance to a location
type PersonWithDistance struct {
Name string `json:"name"`
Surname string `json:"surname"`
LocationName string `json:"location_name"`
DistanceKm float64 `json:"distance_km"`
AccessLevel int `json:"access_level,omitempty"`
}
// LocationReport represents a report for a single location
type LocationReport struct {
LocationName string `json:"location_name"`
Persons []PersonWithDistance `json:"persons"`
}
// SortPersonsByDistance sorts persons by distance (ascending)
func (r *LocationReport) SortPersonsByDistance() {
sort.Slice(r.Persons, func(i, j int) bool {
return r.Persons[i].DistanceKm < r.Persons[j].DistanceKm
})
}
// PersonData holds all gathered data for a person
type PersonData struct {
Person Person
Locations []PersonLocation // Multiple possible locations
AccessLevel int
}