Lat Long
This commit is contained in:
@@ -3,9 +3,6 @@ package request
|
||||
import (
|
||||
"furtuna-be/internal/common/mycontext"
|
||||
"furtuna-be/internal/entity"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Site struct {
|
||||
@@ -26,7 +23,8 @@ type Site struct {
|
||||
Products []Product `json:"products"`
|
||||
Region string `json:"region"`
|
||||
Regency string `json:"regency"`
|
||||
LatLong string `json:"lat_long"`
|
||||
Lat float64 `json:"lat"`
|
||||
Long float64 `json:"long"`
|
||||
}
|
||||
|
||||
func (r *Site) ToEntity(createdBy int64) *entity.Site {
|
||||
@@ -45,17 +43,6 @@ func (r *Site) ToEntity(createdBy int64) *entity.Site {
|
||||
CreatedBy: createdBy,
|
||||
})
|
||||
}
|
||||
latLong := strings.Split(r.LatLong, ".")
|
||||
|
||||
lat, err := strconv.ParseFloat(latLong[0], 64)
|
||||
if err != nil {
|
||||
log.Fatalf("Error converting latitude: %v", err)
|
||||
}
|
||||
|
||||
long, err := strconv.ParseFloat(latLong[1], 64)
|
||||
if err != nil {
|
||||
log.Fatalf("Error converting longitude: %v", err)
|
||||
}
|
||||
|
||||
return &entity.Site{
|
||||
ID: r.ID,
|
||||
@@ -75,8 +62,8 @@ func (r *Site) ToEntity(createdBy int64) *entity.Site {
|
||||
Products: products,
|
||||
Region: r.Region,
|
||||
Regency: r.Regency,
|
||||
Lat: lat,
|
||||
Long: long,
|
||||
Lat: r.Lat,
|
||||
Long: r.Long,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user