GeoController class
Введение
- Описание: Контроллер
GeoControllerпредоставляет конечную точку API для изменения района и расписания у водителя. Точка используется как триггер для hasura. - Маршруты: Обрабатывается POST-запрос по маршруту
/geo/change_driver_district.
Формат запроса
Тело нового и старого заказа содержится в словаре new, old: JSON-объект, содержащий данные заказа, описан в классе TriggerOrderCreateDto.
{
"headers": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "User-Agent",
"value": "hasura-graphql-engine/v2.36.0"
}
],
"payload": {
"created_at": "2025-02-20T14:57:10.516881",
"delivery_info": {
"current_retry": 0,
"max_retries": 0
},
"event": {
"data": {
"new": {
"clientID": 985656,
"comment": "comment",
"createdAt": "2025-02-19T09:51:18.679796+00:00",
"deliveredDate": null,
"deliveryPrice": 0,
"departmentId": 4,
"discountId": null,
"discounts": [],
"districtId": "CL_5",
"driverID": "6964cc22-c639-4bfd-88fd-6d408d88f9c1",
"driverRefuseReasonId": null,
"externalKey": null,
"externalKey_vendorDatalinkId": null,
"externalStatus": null,
"id": 982277,
"important": null,
"isRescheduled": false,
"isReturned": false,
"isSaved": false,
"operatorRefuseReasonId": null,
"paymentExpirationDate": null,
"paymentType": null,
"paymentUrl": null,
"plannedDate": "2025-02-19T09:51:18.679796+00:00",
"plannedDateDuration": 90,
"positionsToBeSent": false,
"reasonRefusal": null,
"resale": false,
"rescheduleCount": 0,
"shipmentId": null,
"shortCode": "TEST-PUSH-NOT",
"statusName": "DriverAssigned",
"statusUpdatedAt": "2025-02-19T10:01:21.744935+00:00",
"system": "amabuyer",
"telegramUserEmail": null,
"test": false,
"totalCents": 300,
"umbrellaID": null,
"districtId": "CL_5",
"updatedAt": "2025-02-19T12:55:19.765799+00:00",
"vendorDatalinkId": 5,
"warehouseID": null
},
"old": {
"clientID": 985656,
"comment": "comment",
"createdAt": "2025-02-19T09:51:18.679796+00:00",
"deliveredDate": null,
"deliveryPrice": 0,
"departmentId": 4,
"discountId": null,
"discounts": [],
"districtId": "CL_5",
"driverID": "6964cc22-c639-4bfd-88fd-6d408d88f9c1",
"driverRefuseReasonId": null,
"externalKey": null,
"externalKey_vendorDatalinkId": null,
"externalStatus": null,
"id": 982277,
"important": null,
"isRescheduled": false,
"isReturned": false,
"isSaved": false,
"operatorRefuseReasonId": null,
"paymentExpirationDate": null,
"paymentType": null,
"paymentUrl": null,
"plannedDate": "2025-02-19T09:51:18.679796+00:00",
"plannedDateDuration": 90,
"positionsToBeSent": false,
"reasonRefusal": null,
"resale": false,
"rescheduleCount": 0,
"shipmentId": null,
"shortCode": "TEST-PUSH-NOT",
"statusName": "DriverAssigned",
"statusUpdatedAt": "2025-02-19T10:01:21.744935+00:00",
"system": "amabuyer",
"telegramUserEmail": null,
"test": false,
"totalCents": 300,
"umbrellaID": null,
"districtId": "CL_12",
"updatedAt": "2025-02-19T12:55:19.765799+00:00",
"vendorDatalinkId": 5,
"warehouseID": null
},
"op": "INSERT",
"session_variables": {
"x-hasura-role": "admin"
},
},
"trace_context": {
"sampling_state": "1",
"span_id": "7a50df8f6ef5dde5",
"trace_id": "8a33d6b0c66033c93f642a7fbcc1d1e5"
}
},
"id": "33d0b4e1-b7a9-4611-a5cb-fe15d3663124",
"table": {
"name": "order",
"schema": "public"
},
"trigger": {
"name": "order_created"
}
},
"version": "2"
}
Валидация и преобразование данных
Контроллер проверяет secret Api.
Основная логика
Данный контроллер используется для привязки водителю другого района и выдачи нового расписания (расписание выдаётся дефолтное). В зависимости от переданной операции (INSERT, UPDATE, DELETE) производится соответствующие действие. Обновлённые данные отправляются в систему Umbrella.
Взаимодействие с микросервисами
- Hasura: Получение запроса на операцию с районом.
- Umbrella: Отправка обновленных данных по району.
Ответы сервера
- Успешное обновили данные по району: Возвращается статус
200 OK - Некорректный secret. Ожидаемый статус -
403 forbidden. - Ресурс не изменился. Ожидаемый статус -
304 Not Modified.
- Inheritance
-
- Object
- Controller
- GeoController
Constructors
Properties
- endpoint ↔ String
-
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- repository → GeoRepository
-
final
- request ↔ Request
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Request request) → FutureOr< Response> -
inherited
-
handler(
) → Future< Response> -
Must be implemented
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requestAsJson(
) → Future -
Reads request value and parse as json
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited