Update the address when provided on a report

This commit is contained in:
Eli Ribble 2026-04-10 20:29:26 +00:00
parent bac55774f8
commit 12aedaf543
No known key found for this signature in database
6 changed files with 82 additions and 9 deletions

View file

@ -4,11 +4,13 @@ import (
"fmt"
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
)
type Address struct {
Country string `db:"country" json:"country"`
GID string `db:"gid" json:"gid" schema:"gid"`
ID *int32 `db:"id" json:"-" schema:"-"`
Locality string `db:"locality" json:"locality"`
Location *Location `db:"location" json:"location" schema:"location"`
Number string `db:"number" json:"number"`
@ -25,3 +27,21 @@ func (a Address) String() string {
func (a Address) CountryEnum() enums.Countrytype {
return enums.CountrytypeUsa
}
func AddressFromModel(m *models.Address) Address {
return Address{
Country: m.Country.String(),
GID: m.Gid,
ID: &m.ID,
Locality: m.Locality,
Location: &Location{
Latitude: m.LocationY.GetOr(0.0),
Longitude: m.LocationX.GetOr(0.0),
},
Number: m.Number,
PostalCode: m.PostalCode,
Raw: "",
Region: m.Region,
Street: m.Street,
Unit: m.Unit,
}
}