Update the address when provided on a report
This commit is contained in:
parent
bac55774f8
commit
12aedaf543
6 changed files with 82 additions and 9 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue