SpeedTow API 文件
tRPC 端點文件 — 共 13 個模組、65 個端點。所有 API 透過 /api/trpc 存取。
auth.*4 個端點使用者認證與個人資料管理
auth.mequerypublic取得目前登入使用者資訊
User | nullauth.getProfilequeryprotected取得使用者完整個人資料
{ id, name, email, phone, address, role, avatarUrl, createdAt }auth.updateProfilemutationprotected更新個人資料
{ name?: string, phone?: string, address?: string }{ success: boolean }auth.logoutmutationpublic登出並清除 session cookie
{ success: true }order.*6 個端點訂單建立、查詢與管理
order.createmutationprotected建立新訂單
{ pickupCity, pickupAddress, deliveryCity, deliveryAddress, vehicleBrand, vehicleModel, vehicleYear?, vehiclePlate?, vehicleColor?, notes?, isUrgent?, pickupDate?, companyId?, userCouponId? }{ id: number }order.getMyOrdersqueryprotected取得使用者所有訂單
Order[]order.getAllqueryadmin取得所有訂單(管理員)
Order[]order.getByIdqueryprotected依 ID 取得訂單詳情
{ id: number }Orderorder.updateStatusmutationadmin更新訂單狀態
{ id: number, status: string }{ success: boolean }order.assignTripmutationadmin指派訂單給班次
{ orderId: number, tripId: number }{ success: boolean }trip.*5 個端點班次(運送趟次)管理
trip.createmutationadmin建立新班次
{ driverId, departureCity, arrivalCity, departureDate, vehicleType, maxCapacity }{ id: number }trip.getAllquerypublic取得所有班次列表
Trip[]trip.getByIdquerypublic依 ID 取得班次詳情
{ id: number }Triptrip.getAvailablequerypublic取得可用班次(看板用)
Trip[]trip.completeByDrivermutationprotected司機完成確認(含簽收、里程)
{ tripId, actualDistanceKm, completionNotes?, signatureUrl? }{ success: boolean }driver.*7 個端點司機資料、定位與排班管理
driver.getMyTripsqueryprotected取得司機的班次列表
Trip[]driver.updateLocationmutationprotected更新司機 GPS 位置
{ lat, lng, speed?, heading?, accuracy?, tripId? }{ success: boolean }driver.updateProfilemutationprotected更新司機個人資料(駕照、車輛)
{ licensePhotoUrl?, licenseExpiry?, vehicleBrand?, vehicleModel?, vehicleYear? }{ success: boolean }driver.myProfilequeryprotected取得司機個人資料
DriverProfiledriver.updateAvailabilitymutationprotected更新排班可用性
{ dayOfWeek, startTime, endTime, isAvailable }{ success: boolean }driver.updateRoutePreferencesmutationprotected更新路線偏好
{ departureCity, arrivalCity, priority }{ success: boolean }driver.reportIncidentmutationprotected通報異常事件
{ orderId?, tripId?, category, subcategory, description?, photoUrls?, suggestedSurcharge? }{ id: number }company.*7 個端點車商(企業)入口管理
company.myCompanyqueryprotected取得使用者的公司資料
Company | nullcompany.createmutationprotected建立新公司
{ name, contactName?, contactPhone?, address? }{ id: number }company.ordersqueryprotected取得公司訂單列表
{ companyId: number }Order[]company.transactionsqueryprotected取得公司交易記錄
{ companyId: number }Transaction[]company.topupmutationprotected公司儲值
{ companyId: number, amount: number }{ success: boolean }company.invoicesqueryprotected取得公司帳單列表
{ companyId: number }Invoice[]company.incidentsqueryprotected取得公司相關異常記錄
{ companyId: number }IncidentReport[]incident.*2 個端點異常事件通報與查詢
incident.reportmutationprotected司機通報異常事件
{ orderId?, tripId?, category, subcategory, description?, photoUrls?, suggestedSurcharge? }{ id: number }incident.myIncidentsqueryprotected取得司機的異常記錄
IncidentReport[]ebol.*2 個端點電子車況記錄(取車/交車照片存證)
ebol.createmutationprotected建立車況記錄
{ orderId, type: 'pickup'|'delivery', photos: string[], notes?, odometerReading?, signatureUrl? }{ id: number }ebol.getByOrderqueryprotected依訂單取得車況記錄
{ orderId: number }EbolRecord[]pricing.*3 個端點定價規則管理
pricing.getRulesqueryadmin取得所有定價規則
PricingRule[]pricing.createRulemutationadmin建立定價規則
{ departureCity, arrivalCity, basePrice, pricePerKm?, vehicleType? }{ id: number }pricing.calculatequerypublic計算運費
{ departureCity, arrivalCity, vehicleType? }{ price: number, rule?: PricingRule }dashboard.*11 個端點管理後台統計與操作
dashboard.statsqueryadmin取得總覽統計數據
{ totalOrders, activeTrips, totalDrivers, revenue, ... }dashboard.incidentListqueryadmin取得所有異常記錄
IncidentReport[]dashboard.resolveIncidentmutationadmin處理異常(核准/駁回/結案)
{ id, status, approvedSurcharge?, adminNotes? }{ success: boolean }dashboard.vehicleDatabasequeryadmin取得車輛資料庫
VehicleRecord[]dashboard.vehicleStatsqueryadmin取得車輛統計
{ totalVehicles, brandDistribution, ... }dashboard.generateInvoicemutationadmin產生月結帳單
{ companyId, month, year }{ id: number }dashboard.invoiceListqueryadmin取得所有帳單
Invoice[]dashboard.schedulingSuggestionsqueryadmin取得智慧排班建議
SchedulingSuggestion[]dashboard.analyticsRevenuequeryadmin營收趨勢分析
{ period, startDate?, endDate? }RevenueData[]dashboard.analyticsDriverPerformancequeryadmin司機績效排名
DriverPerformance[]dashboard.analyticsRoutesqueryadmin熱門路線分析
RouteData[]tracking.*3 個端點即時追蹤與定位
tracking.activeLocationsqueryadmin取得所有活躍司機位置
DriverLocation[]tracking.locationHistoryqueryadmin取得位置歷史軌跡
{ driverId, startTime?, endTime? }LocationLog[]tracking.publicTrackquerypublic客戶自助查詢運送進度
{ orderNumber?: string, phone?: string }TrackingResultnotification.*4 個端點通知管理
notification.getMyNotificationsqueryprotected取得使用者通知列表
Notification[]notification.markAsReadmutationprotected標記通知為已讀
{ id: number }{ success: boolean }notification.getPreferencesqueryprotected取得通知偏好設定
NotificationPreferencesnotification.updatePreferencesmutationprotected更新通知偏好設定
{ category, enabled }{ success: boolean }campaign.*4 個端點活動管理
campaign.listqueryadmin取得所有活動
Campaign[]campaign.createmutationadmin建立新活動
{ title, description, startDate, endDate, ... }{ id: number }campaign.updatemutationadmin更新活動
{ id, ... }{ success: boolean }campaign.deletemutationadmin刪除活動
{ id: number }{ success: boolean }points.*7 個端點會員點數系統
points.getBalancequeryprotected取得點數餘額
{ balance: number }points.getHistoryqueryprotected取得點數歷史記錄
PointTransaction[]points.adminAdjustmutationadmin管理員手動調整點數
{ userId, amount, reason }{ success: boolean }points.redeemCouponmutationprotected兌換優惠券
{ couponTemplateId: number }{ userCouponId: number }points.getMyCouponsqueryprotected取得使用者優惠券
UserCoupon[]points.getReferralCodequeryprotected取得推薦碼
{ code: string }points.applyReferralmutationprotected使用推薦碼
{ code: string }{ success: boolean }SpeedTow API v1.0 — 使用 tRPC 11 + Superjson 傳輸
所有受保護端點需要有效的 session cookie(透過 OAuth 登入取得)