Try   HackMD

URI-G-18 all-category / a to z API

JasonWu

tags: URI-G

內容

舊版網址

相關示意圖

  • 依照分類顯示

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 依照字母順序顯示

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

相關程式

  • 參考 ttcms 程式
    • com.hyweb.tt.cms.cm.webservice.TaitracodeWebService
      • getList > 取得清單
      • formClassify > 組合 classify 內容
      • formAlphaBeta > 組合 a to z 內容
      • sortArticle > 資料排序

Input JSON Path

規格

  • path : ${TT-API網址}/category-view/{type}/{did}
  • method : GET

Input

欄位名稱 欄位說明 資料型態 是否必要欄位 備註
type 類型 string Y 分為 classify 與 atoz 兩種
did domain id number Y int

==舊版紀錄如下

Column Type Require Desc
type string Y 類型,分為 classify 與 atoz 兩種
did number Y domain id

範例

https://tt-api.taiwantrade.com/category-view/classify/2
https://tt-api.taiwantrade.com/category-view/atoz/2

邏輯

  • 認證類型分兩類,對應參數紀錄如下
    • 分類型: classify
    • 字母排序型: atoz
  • 解析 json 內容後顯示
    • 依照傳入不同的類型,回傳的 classify 與 atoz 的內容不同
    • 如果傳入 classify,請解析 classify,atoz 會是空的
    • 反之,如果傳入 atoz,請解析 atoz,classify 會是空的
    • classify 格式,要呈現階層式的效果,需要跟客戶討論 json 格式
      • 直接採用階層式,二碼包四碼,四碼再包六碼
      • 採用二碼一包,四碼一包,六碼一包,顯示時再各自尋找 parent 來組合
      • 目前建議 json 格式採用二碼、四碼、六碼一包的方式
    • atoz 格式,上面要有一排首字母,點選首字母後,跳轉到對應的區塊
  • classify 需求
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
    • 首先需要解析 did,確定是標準 taitra code 還是自訂義 taitra code
      • 如果是標準 taitra code,透過 sql 取值
      • 如果是自訂義 taitra code,透過 idol 取值
    • 貿協希望 classify 也要提供二碼的跳轉效果,請參考圖片,參考網址 : https://www.alibaba.com/Products?spm=a27aq.21734014.scGlobalHomeHeader.360.53c962baI9g7Q1
    • 點選後,跳轉到對應的二碼 classify,這一段可以解析 classify2 取得
    • 依照回報訊息調整,api 回傳的 classify2 的內容排序依照目前的排序效果;api 回傳的 classify4 與 classify6 的排序依照字母來排列,套板時直接依照回傳 api 的排序來顯示
    • classifyDefine 區塊內容資料放的是只有 classify2 資料,但沒有所屬的 classify4 與 classify6,這類的不需要特別的跳轉快捷列,直接顯示即可

Output JSON Path

規格

{ 
    "code" : <code>,
    "errorMsg" : <errorMsg>,
    "intervalTime" : <intervalTime>,
    "data" : {
        "classify2" : [
            {
                "cateId" : <cateId>,
                "parentCateId" : <parentCateId>,
                "title" : <title>,
                "url" : <url>
            },...
        ],
        "classify4" : [
            {
                "cateId" : <cateId>,
                "parentCateId" : <parentCateId>,
                "title" : <title>,
                "url" : <url>
            },...
        ],
        "classify6" : [
            {
                "cateId" : <cateId>,
                "parentCateId" : <parentCateId>,
                "title" : <title>,
                "url" : <url>
            },...
        ],
        "classifyDefine" : [
            {
                "cateId" : <cateId>,
                "parentCateId" : <parentCateId>,
                "title" : <title>,
                "url" : <url>
            },...
        ],
        "atoz" : [
            {
                "cateId" : <cateId>,
                "firstChar" : <firstChar>,
                "title" : <title>,
                "url" : <url>
            },...
        ]    
    }
}

輸出參數說明

all-category / a to z 輸出欄位

欄位名稱 欄位說明 資料型態 是否可為空值 備註
code 執行狀態代碼 number N int
code=0為正常
code<0為錯誤
errorMsg 錯誤訊息 string N
intervalTime 執行時間 string N 顯示執行時間,單位 ms
data 主要輸出欄位 主要輸出欄位(Object) Y 主要輸出欄位

==舊版紀錄如下

欄位名稱 欄位說明 型態 是否可為空值
code 代碼 int 0表示ok
errorMsg 錯誤訊息 string
data 主要輸出欄位 主要輸出欄位(Object)
主要輸出欄位
欄位名稱 欄位說明 資料型態 是否可為空值 備註
classify2 二碼分類 taitra code 分類格式(Object) Y
classify4 四碼分類 taitra code 分類格式(Object) Y
classify6 六碼分類 taitra code 分類格式(Object) Y
classifyDefine 自定義分類 taitra code 分類格式(Object) Y
atoz 字母分類 字母分類格式(Object) Y

==舊版紀錄如下

欄位名稱 欄位說明 型態 是否可為空值
classify2 二碼分類 taitra code 分類格式(Object) Y
classify4 四碼分類 taitra code 分類格式(Object) Y
classify6 六碼分類 taitra code 分類格式(Object) Y
atoz 字母分類 字母分類格式(Object) Y
分類格式taitraCode
欄位名稱 欄位說明 資料型態 是否可為空值 備註
cateId 分類 id number N int
parentCateId 父結點 id number Y int,二碼與自定義為 null,其他四碼六碼必須有值
title 顯示名稱 string N
url 點選後連結的 url string N

==舊版紀錄如下

欄位名稱 欄位說明 型態 是否可為空值
cateId 分類 id int N
parentCateId 父結點 id int 二碼為 null,其他四碼六碼必須有值
sort 順序 int N
title 顯示名稱 string N
url 點選後連結的 url string N
字母分類格式atoz
欄位名稱 欄位說明 資料型態 是否可為空值 備註
cateId 分類 id number N int
firstChar 首字母 string N 首字母為 A~Z,其他的顯示 Other
title 顯示名稱 string N
url 點選後連結的 url string N

==舊版紀錄如下

欄位名稱 欄位說明 型態 是否可為空值
cateId 分類 id int N
firstChar 首字母 string N
sort 順序 int N
title 顯示名稱 string N
url 點選後連結的 url string N

範例

{ 
    "code" : 0,
    "errorMsg" : "",
    "intervalTime" : "4360 ms",
    "data" : {
        "classify2" : [
            {
                "cateId" : 5739,
                "parentCateId" : null,
                "title" : "Agricultural & Food",
                "url": "word=*&cate=5739&type=product&style=gallery&cateName=agricultural-food"
            },
            {
                "cateId" : 5741,
                "parentCateId" : null,
                "title" : "Mineral & Metallurgy",
                "url": "word=*&cate=5741&type=product&style=gallery&cateName=mineral-metallurgy"
            }
        ],
        "classify4" : [
            {
                "cateId" : 5850,
                "parentCateId" : 5739,
                "title" : "Livestock",
                "url": "word=*&cate=5850&type=product&style=gallery&cateName=livestock"
            },
            {
                "cateId" : 5837,
                "parentCateId" : 5741,
                "title" : "Energy Minerals",
                "url": "word=*&cate=5837&type=product&style=gallery&cateName=energy-minerals"
            }
        ],
        "classify6" : [
            {
                "cateId" : 7142,
                "parentCateId" : 5850,
                "title" : "Chicken",
                "url": "word=*&cate=7142&type=product&style=gallery&cateName=chicken"
            },
            {
                "cateId" : 5903,
                "parentCateId" : 5837,
                "title" : "Coal",
                "url": "word=*&cate=5903&type=product&style=gallery&cateName=coal"
            }
        ],
        "classifyDefine": [
            {
                "cateId": 72250,
                "parentCateId": null,
                "title": "temp name",
                "url": "word=*&cate=72250&type=product&style=gallery&cateName=temp-name"
            }
        ],
        "atoz" : [
            {
                "cateId" : 8627,
                "firstChar" : "A",
                "title" : "A / V Switch & Splitter",
                "url": "word=*&cate=8627&type=product&style=gallery&cateName=a-v-switch-splitter"
            },
            {
                "cateId" : 8674,
                "firstChar" : "B",
                "title" : "Baby Bathtub & Bathing Accessories",
                "url": "word=*&cate=8674&type=product&style=gallery&cateName=baby-bathtub-bathing-accessories"
            }
        ]    
    }
}