added manager, driver, order, route, vehicle, warehouse endpoints,models and migrations.

This commit is contained in:
2026-03-23 18:28:01 +05:00
parent f710cda3f3
commit 6e8750a566
22 changed files with 2463 additions and 111 deletions

33
internal/models/route.go Normal file
View File

@@ -0,0 +1,33 @@
package models
import (
"encoding/json"
"time"
"github.com/google/uuid"
)
// Coordinate represents a [longitude, latitude] pair — ORS array format.
type Coordinate [2]float64
type Route struct {
ID uuid.UUID `db:"id"`
OrderID uuid.UUID `db:"order_id"`
DriverID *uuid.UUID `db:"driver_id"`
Coordinates json.RawMessage `db:"coordinates"` // JSONB: [][2]float64
CurrentIndex int `db:"current_index"`
StartedAt *time.Time `db:"started_at"`
FinishedAt *time.Time `db:"finished_at"`
DistanceKm float64 `db:"distance_km"`
DurationSec int `db:"duration_sec"`
Status string `db:"status"` // pending, active, finished
}
// ParseCoordinates unmarshals the raw JSONB coordinates into a typed slice.
func (r *Route) ParseCoordinates() ([]Coordinate, error) {
var coords []Coordinate
if err := json.Unmarshal(r.Coordinates, &coords); err != nil {
return nil, err
}
return coords, nil
}