File size: 3,464 Bytes
df37f6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
from pydantic import BaseModel, Field, field_validator


class TripSearchDTO(BaseModel):
    channel: str = "web_client"
    size: int = 300
    only_online_trip: bool = True
    ticket_count: int
    seat_type_id: list = Field(default_factory=list)
    from_time: int
    to_time: int
    route_ids: list[int]
    origin_office_id: list = Field(default_factory=list)
    dest_office_id: list = Field(default_factory=list)
    postion: list = Field(default_factory=list)
    floor: list = Field(default_factory=list)
    sort_by: list[str] = ["price", "departure_time"]


class TripOptionDTO(BaseModel):
    trip_id: int
    route: str

    @field_validator("trip_id", mode="before")
    def convert_float_to_int(cls, v):
        return int(v) if v is not None else None


class Route(BaseModel):
    name: str | None = None


class TripDTO(BaseModel):
    id: int | None = None
    route_id: int | None = None
    way_id: int | None = None
    route: Route | None = None
    raw_departure_date: str | None = None
    raw_departure_time: str | None = None
    seat_type_name: str | None = None
    price: int | None = None

    @field_validator("id", "price", "route_id", "way_id", mode="before")
    @classmethod
    def convert_float_to_int(cls, v):
        return int(v) if v is not None else None


class CoordinateDTO(BaseModel):
    lat: float
    lon: float


class PickupPointDTO(BaseModel):
    OfficeId: int | None = None
    Name: str | None = None
    Address: str | None = None
    Phone: str | None = None
    PickUp: int | None = None
    TimeOffice: int | None = None
    PointKind: int | None = None
    Note: str | None = None
    PointKindName: str | None = None


class RouteDTO(BaseModel):
    name: str
    route_id: int
    origin_code: str
    origin_name: str
    origin_hub_id: int
    origin_hub_name: str
    origin_hub_office_id: int
    origin_hub_office_name: str
    origin_hub_coords: CoordinateDTO
    dest_code: str
    dest_name: str
    dest_hub_id: int
    dest_hub_name: str
    dest_hub_office_id: int
    dest_hub_office_name: str
    dest_hub_coords: CoordinateDTO
    shuttle_enable: bool
    allow_desktop: bool
    allow_mobile_app: bool
    allow_web_client: bool
    allow_web_admin: bool


class ShuttleZoneResultDTO(BaseModel):
    is_in_zone: bool
    is_allow_user_to_toggle: bool
    distance_to_user: float
    zone: str | None = None
    nearest_pickup_point: str | None = None


class ShuttleOptionDTO(BaseModel):
    is_enable_shuttle: bool
    route: RouteDTO
    origin_result: ShuttleZoneResultDTO
    dest_result: ShuttleZoneResultDTO


class TripItemDTO(BaseModel):
    id: int
    departure_time: int
    raw_departure_time: str
    raw_departure_date: str
    arrival_time: int
    duration: int
    seat_type_id: int
    seat_type_name: str
    price: int
    empty_seat_quantity: int
    route_id: int
    distance: int
    route: RouteDTO
    way_id: int
    allow_online_booking: bool
    online_booking_before: int
    max_seats_per_booking: int
    point_details: str | None = None
    num_price: int
    from_bus_station_address: str
    to_bus_station_address: str
    top_first_floor_quantity: int
    middle_first_floor_quantity: int
    last_first_floor_quantity: int
    top_second_floor_quantity: int
    middle_second_floor_quantity: int
    last_second_floor_quantity: int
    way_name: str
    way_note: str
    pickup_points: list[PickupPointDTO]
    shuttle_option: ShuttleOptionDTO