# URI-G-22 Site Map API > [name=JasonWu] ###### tags: `URI-G` ## 內容 ### 網址 - https://www.taiwantrade.com/sitemap ### 相關示意圖 - sitemap 畫面 ![](https://i.imgur.com/VIy4Ep0.jpg) - 展開分類相關畫面 ![](https://i.imgur.com/a7Fbjgv.jpg) ### 相關程式 - 參考 ttcms 程式 ### Input JSON Path #### 規格 - path : ${TT-API網址}/sitemap/{did} - method : GET #### Input Column | Type | Require | Desc -----------|----------|---------|--------- did | number | Y | domain id #### 範例 ```=json https://tt-api.taiwantrade.com/sitemap/2/42 ``` #### 邏輯 - 透過 api 取值 - api 預期分為 classify2, classify4, classify6 與 others 四類 - 其中 classify2, classify4, classify6 屬於分類的內容 - 請參考 https://hackmd.io/m--zWYhNT7SAskZVnaYUhg 中 classify2, classify4, classify6 的部分 - others 記錄了其他非分類的內容 - home 連結不需要紀錄在 api 中,本身進入時對應的 domain 就是 home 的連結 - 顯示順序 - home 先顯示 - 顯示 category 區塊 - 顯示 others 區塊,依照 others 中的 sort 顯示 ### Output JSON Path #### 規格 ```=json { "code" : <code>, "errorMsg" : <errorMsg>, "data" : { "classify2" : [ { "cateId" : <cateId>, "parentCateId" : <parentCateId>, "sort" : <sort>, "title" : <title>, "url" : <url> },... ], "classify4" : [ { "cateId" : <cateId>, "parentCateId" : <parentCateId>, "sort" : <sort>, "title" : <title>, "url" : <url> },... ], "classify6" : [ { "cateId" : <cateId>, "parentCateId" : <parentCateId>, "sort" : <sort>, "title" : <title>, "url" : <url> },... ], "others" : [ { "sort" : <sort>, "title" : <title>, "url" : <url>, "childItem" : [ "sort" : <sort>, "title" : <title>, "url" : <url> ] },... ] } } ``` #### 輸出參數說明 網站地圖 輸出欄位 |欄位名稱 | 欄位說明 | 型態 | 是否可為空值 | |--------------------|------------- |----------|--------------| |code | 代碼 | int | 0表示ok | |errorMsg | 錯誤訊息 | String | | |classify2 | 二碼分類 | [`taitra code 分類格式(Object)`](#分類格式taitraCode) | Y | |classify4 | 四碼分類 | [`taitra code 分類格式(Object)`](#分類格式taitraCode) | Y | |classify6 | 六碼分類 | [`taitra code 分類格式(Object)`](#分類格式taitraCode) | Y | |others | 其他項目 | [`其他項目(Object)`](#其他項目) | Y | ##### 分類格式taitraCode |欄位名稱 | 欄位說明 | 型態 | 是否可為空值 | |-------------------|-----------------------------|--------|--------------| |cateId | 分類 id | int | N | |parentCateId | 父結點 id | int | 二碼為 null,其他四碼六碼必須有值 | |sort | 順序 | int | N | |title | 顯示名稱 | string | N | |url | 點選後連結的 url | string | N | ##### 其他項目 |欄位名稱 | 欄位說明 | 型態 | 是否可為空值 | |-------------------|-----------------------------|--------|--------------| |sort | 順序 | int | N | |title | 顯示名稱 | string | N | |url | 點選後連結的 url | string | N | |childItem | 子項目 | [`子項目(Object)`](#子項目) | N | ##### 子項目 |欄位名稱 | 欄位說明 | 型態 | 是否可為空值 | |-------------------|-----------------------------|--------|--------------| |sort | 順序 | int | N | |title | 顯示名稱 | string | N | |url | 點選後連結的 url | string | N | #### SQL ```=sql select catalogdef0_.cid as l1_cid, catalogdef0_.catalog_show_name as l1_show_name, catalogdef0_.catalog_name as l1_name, catalogdef0_.catalog_code as l1_catalog_code,catalogdef0_.ACTIVED l1_actived, catalogdef1_.cid as l2_cid, catalogdef1_.catalog_show_name as l2_show_name, catalogdef1_.catalog_name as l2_name, catalogdef1_.catalog_code as l2_catalog_code,catalogdef1_.ACTIVED l2_actived, catalogdef2_.cid as l3_cid, catalogdef2_.catalog_show_name as l3_show_name, catalogdef2_.catalog_name as l3_name, catalogdef2_.catalog_code as l3_catalog_code,catalogdef2_.ACTIVED l3_actived from catalog_define catalogdef0_ left outer join catalog_define catalogdef1_ on catalogdef0_.cid=catalogdef1_.parent_cid left outer join catalog_define catalogdef2_ on catalogdef1_.cid=catalogdef2_.parent_cid where catalogdef0_.master_Id = :masterId and catalogdef0_.PARENT_CID is null order by l1_catalog_code,l2_catalog_code,l3_catalog_code ``` #### 範例 ```=json { "code" : 0, "errorMsg" : "", "data" : { "classify2" : [ { "cateId" : 5739, "parentCateId" : null, "sort" : 1, "title" : "Agricultural & Food", "url" : "agricultural-food-5739-cateGallery.html" }, { "cateId" : 5741, "parentCateId" : null, "sort" : 2, "title" : "Mineral & Metallurgy", "url" : "mineral-metallurgy-5741-cateGallery.html" } ], "classify4" : [ { "cateId" : 5850, "parentCateId" : 5739, "sort" : 1, "title" : "Livestock", "url" : "livestock-5850-cateGallery.html" }, { "cateId" : 5837, "parentCateId" : 5741, "sort" : 1, "title" : "Energy Minerals", "url" : "energy-minerals-5837-cateGallery.html" } ], "classify6" : [ { "cateId" : 7142, "parentCateId" : 5850, "sort" : 1, "title" : "Chicken", "url" : "chicken-7142-cateGallery.html" }, { "cateId" : 5903, "parentCateId" : 5837, "sort" : 1, "title" : "Coal", "url" : "coal-5903-cateGallery.html" } ], "others" : [ { "sort" : 1, "title" : "Key Visuals", "url" : "", "childItem" : [ { "sort" : 1, "title" : "taiwanexcellence", "url" : "https://taiwanexcellence.taiwantrade.com/" } ] }, { "sort" : 2, "title" : "Our Service", "url" : "", "childItem" : [ { "sort" : 1, "title" : "Customized Sourcing Services", "url" : "http://www.taiwantrade.com/mp/customized-sourcing/" }, { "sort" : 2, "title" : "Taiwan Product Magazines", "url" : "http://ibook.taiwantrade.com.tw/" } ] } ] } } ```