Repository navigation
feat(O4+O7): 乘客端可見車輛資訊+車輛快照/司機電話/留言板 - #32
Merged
Merged
Conversation
This was referenced Jul 17, 2026
thothawei
force-pushed
the
claude/o6-cleaning-fee
branch
2 times, most recently
from
July 17, 2026 06:30
98ed4c7 to
17d48cc
Compare
thothawei
force-pushed
the
claude/o4-o7-vehicle-visibility
branch
from
July 17, 2026 06:32
99a5ad7 to
5671332
Compare
O7 車輛快照(migration 000020):rides.driver_vehicle_type/driver_plate_number, 接單時定格(不是完成時——乘客在「前往上車點」階段就要對車)。快照由 AcceptRide 同一個 UPDATE 以子查詢自 drivers 複製,不由呼叫端傳入:與 driver_id 原子性定格、 呼叫端不可能傳錯車,且簽名不變(既有呼叫點與測試零改動)。不加車牌唯一索引—— 快照是歷史紀錄,同一台車本來就會出現在很多趟。 O4 乘客端可見:ride.accepted payload(rideAcceptedCustomerPayload)+ CustomerRideView(內嵌 *model.Ride → JSON 攤平,既有欄位一個不少)帶 driver_name/driver_phone,用於 rides/active 與 rides/:id。送車種 code 而非顯示名; 空值不帶該鍵,寧可少一個鍵也不要讓 App 顯示空白車牌。 來源刻意不同:車種/車牌讀 ride 快照(司機換車後歷史不變),電話讀 drivers 即時值 (換號碼後乘客要撥得通的是新號碼)。 授權順序是重點:GetRideForCustomer 先驗 403 再組司機資訊——顛倒過來會連同 403 把明碼電話一起吐出去(反向驗證確認)。 O7 留言板:確認沿用既有 ride_messages,未新增任何程式。補測試釘住規格要求的行為: 90 天前完成的行程仍可雙向發話與讀歷史,非參與者仍 403(沒有時間限制 ≠ 沒有授權)。 驗收:build/vet/gofmt 綠;service 1164s、repository 635s、handler 50s、constants 全套通過。反向驗證:移除快照寫入 → 快照為空 FAIL;授權移到組資料之後 → 403 連同 DriverPhone 一起回傳 FAIL。 順帶把 N 的兩個待拍板寫進 TODO(2026-07-17 使用者拍板):picked_up 維持單一時間點 (第一位上車);司機可標記跳過缺席乘客 → N7 由「可選」變必要,且跳過的停靠點不計入 N5 計費路線。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
thothawei
force-pushed
the
claude/o4-o7-vehicle-visibility
branch
from
July 17, 2026 06:32
5671332 to
972003a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
實作 O4(乘客端可見車輛資訊) 與 O7(車輛快照+司機聯絡方式+留言板)。至此 O 章節只剩 O5(可選、待拍板)。
O7-1 車輛快照(migration 000020)
rides.driver_vehicle_type/driver_plate_number,接單時定格——不是完成時,因為乘客在「司機前往上車點」階段就要對車。快照由
AcceptRide的同一個 UPDATE 以子查詢自drivers複製,不由呼叫端傳入:driver_id原子性定格,不會有「接了單但快照還沒寫」的中間狀態;AcceptRide簽名不變,既有呼叫點與測試零改動。不加車牌唯一索引——快照是歷史紀錄,同一台車本來就會出現在很多趟行程上。
O4 + O7-2 乘客端可見
ride.acceptedpayload →rideAcceptedCustomerPayload(收件人是ride.CustomerID一人)GET /api/customer/rides/active、GET /api/customer/rides/:id→CustomerRideViewCustomerRideView內嵌*model.Ride讓 JSON 攤平,既有欄位一個不少,只多driver_name/driver_phone。兩者的正確來源不同,刻意沒統一:
送車種 code 而非顯示名(O1 原則)。空值不帶該鍵(而非空字串)——寧可少一個鍵,也不要讓 App 顯示空白車牌。
授權順序=明碼電話的分界
GetRideForCustomer先驗403再組司機資訊。顛倒過來就會連同 403 把明碼電話一起吐出去——反向驗證確認測試會抓到(403回應裡出現DriverPhone:0912345678)。O7-3 留言板:未新增任何程式
既有
authorizeRideParticipant只看「是否本趟參與者」,不看狀態也不看時間 → 行程完成很久後本來就能對話。但規格明確要求「實作前要寫一個測試釘住這個行為」,所以補了TestChat_行程完成很久之後仍可對話:90 天前完成的行程,乘客發話/司機回話/讀歷史皆可,非參與者仍 403——「沒有時間限制」不等於「沒有授權」。驗收(實際跑過)
go build/go vet/gofmt綠;service 1164s、repository 635s、handler 50s、constants 全套通過。rideAcceptedCustomerPayload(帶車種/車牌/電話;空值不帶鍵)。TestAcceptRide車輛快照定格(司機換車後歷史快照不變)、TestGetActiveRideByCustomer帶司機資訊(含「既有 ride 欄位不得因換成 view 而消失」)、TestGetRideForCustomer電話僅本人可見、TestChat_行程完成很久之後仍可對話。未驗:docker compose 起全服務的 live E2E。
範圍說明
ride_id呼叫GET /api/customer/rides/:id即可取得(該路徑已帶電話且無時間限制)。順帶
把 N 章節的兩個待拍板寫進 TODO(2026-07-17 使用者拍板):
picked_up維持單一時間點(第一位乘客上車)——F 報表、tracking 里程起點、三端對帳皆不受影響;ride_stops.arrived_at保留為日後精確化的升級路徑。下一步
N(多乘客/多停靠點),分三批:N1+N2+N3(
ride_stops表/驗證/建單 API)→ N4+N6+N7(payload 帶 stops/到站與跳過標記)→ N5(OSRM 多 waypoint 計費,排除已跳過)。🤖 Generated with Claude Code