SpeedTow API 文件

tRPC 端點文件 — 共 13 個模組、65 個端點。所有 API 透過 /api/trpc 存取。

query讀取資料
mutation寫入/修改資料
public無需登入
protected需要登入
admin管理員專用
Authauth.*4 個端點

使用者認證與個人資料管理

auth.mequerypublic

取得目前登入使用者資訊

Output: User | null
auth.getProfilequeryprotected

取得使用者完整個人資料

Output: { id, name, email, phone, address, role, avatarUrl, createdAt }
auth.updateProfilemutationprotected

更新個人資料

Input: { name?: string, phone?: string, address?: string }
Output: { success: boolean }
auth.logoutmutationpublic

登出並清除 session cookie

Output: { success: true }
Orderorder.*6 個端點

訂單建立、查詢與管理

order.createmutationprotected

建立新訂單

Input: { pickupCity, pickupAddress, deliveryCity, deliveryAddress, vehicleBrand, vehicleModel, vehicleYear?, vehiclePlate?, vehicleColor?, notes?, isUrgent?, pickupDate?, companyId?, userCouponId? }
Output: { id: number }
order.getMyOrdersqueryprotected

取得使用者所有訂單

Output: Order[]
order.getAllqueryadmin

取得所有訂單(管理員)

Output: Order[]
order.getByIdqueryprotected

依 ID 取得訂單詳情

Input: { id: number }
Output: Order
order.updateStatusmutationadmin

更新訂單狀態

Input: { id: number, status: string }
Output: { success: boolean }
order.assignTripmutationadmin

指派訂單給班次

Input: { orderId: number, tripId: number }
Output: { success: boolean }
Triptrip.*5 個端點

班次(運送趟次)管理

trip.createmutationadmin

建立新班次

Input: { driverId, departureCity, arrivalCity, departureDate, vehicleType, maxCapacity }
Output: { id: number }
trip.getAllquerypublic

取得所有班次列表

Output: Trip[]
trip.getByIdquerypublic

依 ID 取得班次詳情

Input: { id: number }
Output: Trip
trip.getAvailablequerypublic

取得可用班次(看板用)

Output: Trip[]
trip.completeByDrivermutationprotected

司機完成確認(含簽收、里程)

Input: { tripId, actualDistanceKm, completionNotes?, signatureUrl? }
Output: { success: boolean }
Driverdriver.*7 個端點

司機資料、定位與排班管理

driver.getMyTripsqueryprotected

取得司機的班次列表

Output: Trip[]
driver.updateLocationmutationprotected

更新司機 GPS 位置

Input: { lat, lng, speed?, heading?, accuracy?, tripId? }
Output: { success: boolean }
driver.updateProfilemutationprotected

更新司機個人資料(駕照、車輛)

Input: { licensePhotoUrl?, licenseExpiry?, vehicleBrand?, vehicleModel?, vehicleYear? }
Output: { success: boolean }
driver.myProfilequeryprotected

取得司機個人資料

Output: DriverProfile
driver.updateAvailabilitymutationprotected

更新排班可用性

Input: { dayOfWeek, startTime, endTime, isAvailable }
Output: { success: boolean }
driver.updateRoutePreferencesmutationprotected

更新路線偏好

Input: { departureCity, arrivalCity, priority }
Output: { success: boolean }
driver.reportIncidentmutationprotected

通報異常事件

Input: { orderId?, tripId?, category, subcategory, description?, photoUrls?, suggestedSurcharge? }
Output: { id: number }
Companycompany.*7 個端點

車商(企業)入口管理

company.myCompanyqueryprotected

取得使用者的公司資料

Output: Company | null
company.createmutationprotected

建立新公司

Input: { name, contactName?, contactPhone?, address? }
Output: { id: number }
company.ordersqueryprotected

取得公司訂單列表

Input: { companyId: number }
Output: Order[]
company.transactionsqueryprotected

取得公司交易記錄

Input: { companyId: number }
Output: Transaction[]
company.topupmutationprotected

公司儲值

Input: { companyId: number, amount: number }
Output: { success: boolean }
company.invoicesqueryprotected

取得公司帳單列表

Input: { companyId: number }
Output: Invoice[]
company.incidentsqueryprotected

取得公司相關異常記錄

Input: { companyId: number }
Output: IncidentReport[]
Incidentincident.*2 個端點

異常事件通報與查詢

incident.reportmutationprotected

司機通報異常事件

Input: { orderId?, tripId?, category, subcategory, description?, photoUrls?, suggestedSurcharge? }
Output: { id: number }
incident.myIncidentsqueryprotected

取得司機的異常記錄

Output: IncidentReport[]
eBOLebol.*2 個端點

電子車況記錄(取車/交車照片存證)

ebol.createmutationprotected

建立車況記錄

Input: { orderId, type: 'pickup'|'delivery', photos: string[], notes?, odometerReading?, signatureUrl? }
Output: { id: number }
ebol.getByOrderqueryprotected

依訂單取得車況記錄

Input: { orderId: number }
Output: EbolRecord[]
Pricingpricing.*3 個端點

定價規則管理

pricing.getRulesqueryadmin

取得所有定價規則

Output: PricingRule[]
pricing.createRulemutationadmin

建立定價規則

Input: { departureCity, arrivalCity, basePrice, pricePerKm?, vehicleType? }
Output: { id: number }
pricing.calculatequerypublic

計算運費

Input: { departureCity, arrivalCity, vehicleType? }
Output: { price: number, rule?: PricingRule }
Dashboarddashboard.*11 個端點

管理後台統計與操作

dashboard.statsqueryadmin

取得總覽統計數據

Output: { totalOrders, activeTrips, totalDrivers, revenue, ... }
dashboard.incidentListqueryadmin

取得所有異常記錄

Output: IncidentReport[]
dashboard.resolveIncidentmutationadmin

處理異常(核准/駁回/結案)

Input: { id, status, approvedSurcharge?, adminNotes? }
Output: { success: boolean }
dashboard.vehicleDatabasequeryadmin

取得車輛資料庫

Output: VehicleRecord[]
dashboard.vehicleStatsqueryadmin

取得車輛統計

Output: { totalVehicles, brandDistribution, ... }
dashboard.generateInvoicemutationadmin

產生月結帳單

Input: { companyId, month, year }
Output: { id: number }
dashboard.invoiceListqueryadmin

取得所有帳單

Output: Invoice[]
dashboard.schedulingSuggestionsqueryadmin

取得智慧排班建議

Output: SchedulingSuggestion[]
dashboard.analyticsRevenuequeryadmin

營收趨勢分析

Input: { period, startDate?, endDate? }
Output: RevenueData[]
dashboard.analyticsDriverPerformancequeryadmin

司機績效排名

Output: DriverPerformance[]
dashboard.analyticsRoutesqueryadmin

熱門路線分析

Output: RouteData[]
Trackingtracking.*3 個端點

即時追蹤與定位

tracking.activeLocationsqueryadmin

取得所有活躍司機位置

Output: DriverLocation[]
tracking.locationHistoryqueryadmin

取得位置歷史軌跡

Input: { driverId, startTime?, endTime? }
Output: LocationLog[]
tracking.publicTrackquerypublic

客戶自助查詢運送進度

Input: { orderNumber?: string, phone?: string }
Output: TrackingResult
Notificationnotification.*4 個端點

通知管理

notification.getMyNotificationsqueryprotected

取得使用者通知列表

Output: Notification[]
notification.markAsReadmutationprotected

標記通知為已讀

Input: { id: number }
Output: { success: boolean }
notification.getPreferencesqueryprotected

取得通知偏好設定

Output: NotificationPreferences
notification.updatePreferencesmutationprotected

更新通知偏好設定

Input: { category, enabled }
Output: { success: boolean }
Campaigncampaign.*4 個端點

活動管理

campaign.listqueryadmin

取得所有活動

Output: Campaign[]
campaign.createmutationadmin

建立新活動

Input: { title, description, startDate, endDate, ... }
Output: { id: number }
campaign.updatemutationadmin

更新活動

Input: { id, ... }
Output: { success: boolean }
campaign.deletemutationadmin

刪除活動

Input: { id: number }
Output: { success: boolean }
Pointspoints.*7 個端點

會員點數系統

points.getBalancequeryprotected

取得點數餘額

Output: { balance: number }
points.getHistoryqueryprotected

取得點數歷史記錄

Output: PointTransaction[]
points.adminAdjustmutationadmin

管理員手動調整點數

Input: { userId, amount, reason }
Output: { success: boolean }
points.redeemCouponmutationprotected

兌換優惠券

Input: { couponTemplateId: number }
Output: { userCouponId: number }
points.getMyCouponsqueryprotected

取得使用者優惠券

Output: UserCoupon[]
points.getReferralCodequeryprotected

取得推薦碼

Output: { code: string }
points.applyReferralmutationprotected

使用推薦碼

Input: { code: string }
Output: { success: boolean }

SpeedTow API v1.0 — 使用 tRPC 11 + Superjson 傳輸

所有受保護端點需要有效的 session cookie(透過 OAuth 登入取得)