This commit is contained in:
aditya.siregar
2024-08-14 23:44:34 +07:00
parent 99a569afb3
commit 1a9d04a2d9
3 changed files with 8 additions and 20 deletions
+4 -17
View File
@@ -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,
}
}