Lat Long
This commit is contained in:
parent
99a569afb3
commit
1a9d04a2d9
@ -1,7 +1,6 @@
|
||||
package site
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"furtuna-be/internal/common/errors"
|
||||
"furtuna-be/internal/entity"
|
||||
"furtuna-be/internal/handlers/request"
|
||||
@ -288,7 +287,8 @@ func (h *Handler) toSiteResponse(resp *entity.Site) response.Site {
|
||||
CreatedAt: resp.CreatedAt.Format(time.RFC3339),
|
||||
UpdatedAt: resp.UpdatedAt.Format(time.RFC3339),
|
||||
Products: h.toProductResponseList(resp.Products),
|
||||
LatLong: fmt.Sprintf("%f,%f", resp.Lat, resp.Long),
|
||||
Lat: resp.Lat,
|
||||
Long: resp.Long,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ type Site struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
Products []Product `json:"products"`
|
||||
LatLong string `json:"lat_long"`
|
||||
Lat float64 `json:"lat"`
|
||||
Long float64 `json:"long"`
|
||||
}
|
||||
|
||||
type SiteName struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user