Appearance
賽果查詢(開發文檔)
最後更新:2026-04-10
📖 功能說明請參考 賽果查詢
架構
相關檔案
ViewController / ViewModel(5 個)
| 檔案 | 說明 |
|---|---|
.../New/NewMatchResultViewController.swift | 賽果列表 VC |
.../New/NewMatchResultView.swift | 賽果列表 View |
.../New/NewMatchResultViewModel.swift | 賽果列表 VM |
.../Detail/MatchResultDetailViewController.swift | 詳情 VC |
.../Detail/MatchResultDetailViewModel.swift | 詳情 VM |
基礎路徑:
BBSport/Tab/我的/Mine/SportMenu/EventResult/
Model(12 個)
| 檔案 | 說明 |
|---|---|
.../Detail/Model/MatchDetailModel+FootBall.swift | 足球詳情 Model |
.../Detail/Model/MatchDetailModel+BasketBall.swift | 籃球詳情 Model |
.../Detail/Model/MatchDetailModel+Tennis.swift | 網球詳情 Model |
.../Detail/Model/MatchDetailModel+VolleyBall.swift | 排球詳情 Model |
.../Detail/Model/MatchDetailModel+IceHockey.swift | 冰球詳情 Model |
.../Detail/Model/MatchDetailModel+BaseBall.swift | 棒球詳情 Model |
.../Detail/Model/MatchDetailModel+AmericanFootBall.swift | 美式足球詳情 Model |
.../Detail/Model/MatchDetailModel+MMA.swift | MMA 詳情 Model |
.../Detail/Model/MatchDetailModel+Snooker.swift | 斯諾克詳情 Model |
.../Detail/Model/MatchDetailModel+Rugby.swift | 橄欖球詳情 Model |
.../Detail/Model/MatchDetailModel+Convert.swift | Model 轉換工具 |
基礎路徑:
BBSport/Tab/我的/Mine/SportMenu/EventResult/
聯賽篩選(1 個)
| 檔案 | 說明 |
|---|---|
.../LeagueFilter/LeagueFilterViewController.swift | 聯賽篩選 VC |
基礎路徑:
BBSport/Tab/我的/Mine/SportMenu/EventResult/
DB 本地快取(4 個)
| 檔案 | 說明 |
|---|---|
.../DB/MatchResultDB.swift | DB 基底類 |
.../DB/FBMatchResultDB.swift | FB 快取 |
.../DB/UPMatchResultDB.swift | UP 快取 |
.../DB/DBMatchResultDB.swift | DB 快取 |
基礎路徑:
BBSport/Tab/我的/Mine/SportMenu/EventResult/
API Request(6 個)
| 檔案 | 說明 |
|---|---|
BBSport/API/FBSportAPI/MatchResult/FBSportAPI+MatchResultListRequest.swift | FB 賽果列表 |
BBSport/API/FBSportAPI/MatchResult/FBSportAPI+MatchResultDetailRequest.swift | FB 賽果詳情 |
BBSport/API/UPSportAPI/MatchResult/UPSportAPI+MatchResultListRequest.swift | UP 賽果列表 |
BBSport/API/UPSportAPI/MatchResult/UPSportAPI+MatchResultDetailRequest.swift | UP 賽果詳情 |
BBSport/API/DBSportAPI/Sport/DBSportAPI+MatcheResultRequest.swift | DB 賽果 |
BBSport/API/DBSportAPI/Sport/DBSportAPI+ChampionMatchResultRequest.swift | DB 冠軍賽果 |
API
賽果列表
FB/UP 賽果列表
POST v1/match/matchResultPage — JSON — 來源:FBSportAPI / UPSportAPI
TIP
FB 與 UP endpoint 相同,差異在 Request struct 分屬不同 namespace。
Request:
| 參數 | 型別 | 必填 | 說明 |
|---|---|---|---|
| sportId | int | 球類 ID(與 leagueIds 二擇一) | |
| leagueIds | [int] | 聯賽 ID 陣列(有值時取代 sportId) | |
| beginTime | double | ✅ | 篩選開始時間(時間戳) |
| endTime | double | ✅ | 篩選結束時間 |
| languageType | string | ✅ | 固定 "CMN" |
| current | int | ✅ | 頁碼,從 1 開始 |
| size | int | ✅ | 每頁數量,預設 20 |
| matchType | int | ✅ | 1=冠軍、2=常規賽事 |
Response:(success=true 時 data,型別 MatchResultListRequest.Response)
| 欄位 | 型別 | 說明 |
|---|---|---|
| records | [STEventModel] | 賽果列表 |
| current | Int | 當前頁碼 |
| size | Int | 每頁數量 |
| total | Int | 總筆數 |
| isLastPage | Bool | 是否最後一頁(計算:current >= ceil(total/size)) |
FB/UP 賽果詳情
POST v1/match/matchResultInfo — JSON — 來源:FBSportAPI / UPSportAPI
| 參數 | 型別 | 必填 | 說明 |
|---|---|---|---|
| matchId | string | ✅ | 賽事 ID |
| languageType | string | ✅ | 固定 "CMN" |
Response:(success=true 時 data,型別 STEventModel)
| 欄位 | 型別 | 說明 |
|---|---|---|
| id | Int | 賽事 ID |
| sid | Int | 球類 ID |
| lg | STLeagueModel | 聯賽資料 |
| ts | [STLeagueModel] | 球隊陣列(ts[0]=主隊、ts[1]=客隊) |
| mg | [STMarketGroupModel] | 盤口集合 |
| mgs | [STMarketGroupModel] | 賽果 API 盤口 |
| sg | [STEventResultModel] | 比分資訊 |
| bt | Double | 開賽時間 |
| ms | MatchStatus | 賽事狀態 |
| result | EventScoreboardModel | 比分看板 |
| ...及其他 15+ 個欄位 |
DB 賽果列表
POST yewu11/v1/m/matcheResultPB — JSON — 來源:DBSportAPI
Request:
| 參數 | 型別 | 必填 | 說明 |
|---|---|---|---|
| euid | string | ✅ | 運動 ID |
| type | int | ✅ | 固定 28(賽果類型) |
| sort | int | ✅ | 固定 1(按聯賽排序) |
| md | string | ✅ | 日期篩選(時間戳字串),預設當天 |
Response:(code="0000000" 時 data,型別 [OBEventModel])
OBEventModel 賽果欄位
| 欄位 | 型別 | 說明 |
|---|---|---|
| mid | String | 賽事 ID |
| tid | String | 聯賽 ID |
| tn | String | 聯賽名稱 |
| csid | String | 球類 ID |
| csna | String | 球類名稱 |
| mhn | String | 主隊名稱 |
| mhid | String | 主隊 ID |
| man | String | 客隊名稱 |
| maid | String | 客隊 ID |
| msc | [String] | 比分集合(格式:S1|1:0) |
| ms | Int? | 賽事狀態(3=結束) |
| mgt | String | 開賽時間(毫秒時間戳) |
| mgt_str | String | 格式化開賽時間 |
| mcg | Int | 欄目類型 |
| mmp | String | 比賽階段 |
| mhs | Int | 盤口狀態(0=開、1=封、2=關、11=鎖) |
| mhlu | [String] | 主隊 Logo URL |
| malu | [String] | 客隊 Logo URL |
| mo | Int | 比賽是否結束 |
DB 冠軍賽果
POST yewu11/api/result/championMatchResultPB — JSON — 來源:DBSportAPI
| 參數 | 型別 | 必填 | 說明 |
|---|---|---|---|
| startTime | string | ✅ | 篩選開始時間 |
| endTime | string | ✅ | 篩選結束時間 |
Response: JSON String,由 DBSportParseJSONStringDecision 處理。
ViewModel 關鍵屬性
| 屬性 | 說明 |
|---|---|
| sourceType | 當前平台(STBindingVariable<GameType>) |
| filterLeagueIds | 已選聯賽 ID(0 筆=全選) |
| isRenew | 是否強制刷新 |
| delayUpdate | 防連續呼叫的延遲更新 |
實作重點
- 平台切換:
supportSourceTypes依GameStatusManager動態決定;切換時重置篩選條件 - 防抖更新:
filterLeagueIds改變 →delayUpdate.call()延遲執行,避免多次請求 - 多球類 Model 擴展:詳情頁各球類以 Swift Extension 分離,共 10 種球類
- 本地快取:
MatchResultDB<T>泛型機制,以(sportType, dateText)為 key 儲存,使用CurrentValueSubject驅動 UI。快取過期策略:今日資料 5 分鐘(300 秒)後過期自動重新請求,非今日資料不過期。reqeust(renew:)傳true可強制刷新。 - 聯賽篩選:以首字母分組,使用
SectionIndexView快速跳轉
關鍵數字
- FB/UP 每頁數量:20 條
- 支援球類數量:10 種(足球/籃球/網球/排球/冰球/棒球/美式足球/MMA/斯諾克/橄欖球)
- 快取過期時間:今日資料 5 分鐘,非今日資料不過期
查無賽果情境
- FB/UP:API 回傳
success=true但records為空陣列,total=0,UI 顯示空狀態 - DB:API 回傳
code="0000000"但data為空陣列,UI 顯示空狀態 - API 請求失敗時,
MatchResultDB狀態保持updating,UI 繼續顯示快取資料(如有);DB 失敗錯誤會 printLog 記錄