final
This commit is contained in:
32
internal/domain/report.go
Normal file
32
internal/domain/report.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user