owned this note
owned this note
Published
Linked with GitHub
# URI-D-01 Offer to sell 列表頁 / 搜尋API
###### tags: `CP頁` `API`
> [name=Tony Fan, Kenshi Chen]
## 內容
### 相關頁面
* Offer to sell 列表頁/ 搜尋結果頁
* 網址 : https://hackmd.io/s6C1TmmnTDCUXSgoM61q7Q
* Offer to sell 首頁
* 網址 : https://hackmd.io/emFxf9h0TSi4dPDKDFAIAA
### 程式
- com/hyweb/tt/cms/front/service/searchpagedata/TradePostSearchListPageData.java
- com/hyweb/tt/cms/cm/idol/tradepost/*
### Input JSON Path
#### 規格
- path : `${TT-API網址}/trade-posts/search/{did}`
- method : POST
- query : 無
- body :
```
{
"keyword": <keyword>,
"options" : <options>, // 0|1|2
"subWord": <subWord>,
"groups": [
{
"groupKey": <groupKey>,
"groupValue": <groupValue>
},
{
"groupKey": <groupKey>,
"groupValue": <groupValue>
},
...
],
"postCategory" : <postCategory>,
"postContinent" : <postContinent>,
"postCountry" : <postCountry>,
"postStartDate": <postStartDate>,
"postEndDate": <postEndDate>,
"rangeSize": <rangeSize>, // 10|20|30
"currpage": <currpage>,
"sort": <sort>, // asc|desc
"searchAesUrl": <searchAesUrl>, //Y|N
"groupAesUrl": <groupAesUrl>, //Y|N
"showIdolUrl": <showIdolUrl>
}
```
#### 輸入參數說明
以下說明輸入的body (json format)的各個attribute。
輸入欄位
| 欄位名稱 | 欄位說明 | 型態 | 說明 | 是否可為空值|
| -------- | -------- | -------- | -------- |-------- |
| keyword | 關鍵字 | String | | 是|
| options | 搜尋類型 | int | | 是|
| subWord | 再搜尋關鍵字 | String | | 是|
| groups | 後分類 | [`後分類條件欄位(Array Object)`](#後分類條件欄位(groups)) | | 是|
| postCategory | 商機產業別 | int | | 是|
| postContinent | 發送者公司註冊洲別 | int | | 是|
| postCountry | 發送者公司註冊國家 | int | | 是|
| postStartDate | 商機張貼開始日期 | int(日期) | valid date start | 是|
| postEndDate | 商機張貼結束日期 | int(日期) | valid date end | 是|
| rangeSize | 每頁最大顯示個數 | int | | 是|
| currpage | 查詢頁數 | int | | 是|
| sort | 排序方式 | String | Post Date(DB對應:audit_date) desc 或 asc | 是|
| searchAesUrl | 是否回傳searchAesUrl:{Y/N} | String | | 是|
| groupAesUrl | 是否回傳groupAesUrl:{Y/N} | String | | 是|
| showIdolUrl | 顯示回傳idolUrl | String | 除錯使用:輸入一組key,符合則顯示解碼後的searchAesUrl和groupAesUrl,預設不顯示 | 是|
* options : 預設為0
* 0: Match all words <br/>
* 1: With the exact phrase <br/>
* 2: Match any word
* 
* rangeSize:{10/20/30}
* 預設:10
* searchAesUrl:{Y/N}
* groupAesUrl:{Y/N}
* sort:預設desc
* desc : 依照張貼時間新到舊排序 <br/>
* asc : 依照張貼時間舊到新排序
##### 後分類條件欄位(groups)
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- | -------- |
| groupKey | 後分類類別 | String | |
| groupValue | 後分類值 | String | |
* groupKey : 不同分類對應不同的key名稱
* Categories : post-category = CATALOG_ID_AUTNMPS <br/>
* ~~Continent : post-continent = NATION_ID_AUTNMPS~~ <br/>
* Country : post-country = BUSINESS_NATION_CODE_AUTNMPS <br/>
* ~~Post Date : post-day = POST_DATE~~
* groupValue : 對應不同分類,值範圍如下:
* Categories : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-category 查詢出來的清單代碼 <br/>
* ~~Continent : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-continent 查詢出來的清單代碼~~ <br/>
* Country : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-country 查詢出來的清單代碼 <br/>
* ~~Post Date : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-day 查詢出來的清單代碼~~
### 範例
#### 舊網查詢方式
https://trading-post.taiwantrade.com/tradepost/search?word=company&type=post&sord=desc&group2=BUSINESS_NATION_CODE_AUTNMPS&groupVal2=583&post_sell=sell&post_offerType=1720&post_continent=430&seo_categoryNames=Viet+Nam
#### (新)API查詢範例
```=json
https://tt-api.taiwantrade.com/trade-posts/search/701
```
* 參考 [URI-D-01 測試案例](https://docs.google.com/spreadsheets/d/16ArA8CY3O2JAkmONj0NNoD37xQK3IYodvwEWipyqtno/edit#gid=1093005017)
### Output JSON Path
#### 規格
```=json
{
"code" : <code>,
"errorMsg" : <errorMsg>,
"data": {
"totalpages": <totalpages>,
"currpage": <currpage>,
"totalrecords": <totalrecords>,
"startRow": <startRow>,
"endRow": <endRow>,
"rangeSize": <rangeSize>,
"rows": [
{
"aid": <aid>,
"seq": <seq>,
"subject": <subject>,
"url": <url>,
"offerTypeId": <offerTypeId>,
"offerType": <offerType>,
"companyId": <companyId>,
"catalogId": <catalogId>,
"catalogName": <catalogName>,
"image": <image>,
"countryId":<countryId>,
"country": <country>,
"validBeginDate": <validBeginDate>,
"validEndDate": <validEndDate>,
"postDate": <postDate>,
"postDateDiff": <postDateDiff>
},
...
],
"groups": [
{
"name": <name>,
"count": null,
"fieldName": <fieldName>,
"id": null,
"sort": <sort>,
"subItem": [
{
"name": <name>,
"count": <count>,
"fieldName": <fieldName>,
"id": <id>,
"sort": <sort>
},
...
]
},
...
],
"queryUrls": {
"searchAesUrl": <searchAesUrl>,
"groupAesUrl" <groupAesUrl>
}
}
}
```
#### 輸出參數說明
輸出欄位
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- | -------- |
| code | 代碼 | int | 0表示ok |
| errorMsg | 錯誤訊息 | String | |
| totalpages | 共計幾頁 | int | N |
| currpage | 目前頁次 | int | N |
| totalrecords | 總筆數 | int | N |
| startRow | 起始筆數 | int | N |
| endRow | 結束筆數 | int | N |
| rangeSize | 本頁筆數 | int | N |
| rows | 資料列表 | [`列表內容欄位(Array Object)`](#列表內容欄位(rows)) | |
| groups | 後分類列表 | [`後分類內容欄位(Array Object)`](#後分類內容欄位(groups)) | |
| queryUrls | idol url | [`Query Url欄位(Object)`](#QueryUrl欄位) | |
##### 列表內容欄位(rows)
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- | -------- |
| aid | 商機 ID | int | N |
| seq | trade post 排序 | int | N |
| subject | 商機標題 | String | N |
| url | 商機(trade post)Cp頁URL(根據輸入的did去組domain,參考TradePostSearchListPageData.java #290) | String | N |
| offerTypeId | 商機類型代碼 | int | N |
| offerType | 商機類型名稱 | String | N |
| companyId | 發送者公司CID | int | N |
| catalogId | 商機分類 ID (標準taitra) | int | N |
| catalogName | 商機分類 名稱 (標準taitra) | String | N |
| image | 圖片URL | String | |
| countryId | 發送者公司註冊國家ID | int | |
| country | 發送者公司註冊國家 | String | |
| validBeginDate | 商機有效起始日期 | int(日期) | |
| validEndDate | 商機有效截止日期(即有效日期:Cp頁的valid_date) | int(日期) | |
| postDate | 商機張貼日期(audit_date) | int(日期) | |
| postDateDiff | 商機張貼日期(格式: x M y D -> 距今過了幾月幾日) | int | |
##### 後分類內容欄位(groups)
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- |-------- |
| name | 分類標題(顯示名稱) | String | N |
| count | 資料筆數 | int | 固定空值 |
| [fieldName](#fieldName--不同分類對應不同的key名稱-亦可作為輸入的-groupKey-去查詢) | 欄位名稱 | String | 對應輸入的groupKey |
| ~~groupBy~~ | ~~分類依據~~ | ~~String~~ | ~~同fieldName~~ |
| id | 資料ID | String | 固定空值,後分類項目才有值 |
| sort | 分類排序 | int | N |
| subItem | 分類項目 | [`後分類項目內容欄位(Array Object)`](#後分類項目內容欄位(subItem)) | |
##### 後分類項目內容欄位(subItem)
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- |-------- |
| name | 項目名稱(顯示名稱) | String | N |
| count | 資料筆數 | int | N (項目資料若為0筆不會回傳) |
| fieldName | 欄位(後分類)名稱 | String | |
| [id](#id--亦可作為輸入的-groupValue-去查詢-對應不同分類,值範圍如下) | 資料ID(後分類值) | String | |
| sort | 項目排序 | int | N |
###### fieldName : 不同分類對應不同的key名稱 (亦可作為[輸入的 groupKey](#後分類條件欄位(groups)) 去查詢)
* Categories : post-category = CATALOG_ID_AUTNMPS <br/>
* ~~Continent : post-continent = NATION_ID_AUTNMPS~~ <br/>
* Country : post-country = BUSINESS_NATION_CODE_AUTNMPS <br/>
* ~~Post Date : post-day = POST_DATE~~
###### id : (亦可作為[輸入的 groupValue](#後分類條件欄位(groups)) 之查詢) 對應不同分類,值範圍如下
* Categories : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-category 查詢出來的清單代碼 <br/>
* ~~Continent : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-continent 查詢出來的清單代碼~~ <br/>
* Country : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-country 查詢出來的清單代碼 <br/>
* ~~Post Date : ([URI054](https://docs.google.com/spreadsheets/d/1I4Zbb8aJw4Ndt-e6Pw3pdBtQMZg1DNlHsRvg7YogstU/edit#gid=0))用post-day 查詢出來的清單代碼~~
##### QueryUrl欄位
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- |-------- |
| searchAesUrl | trade post列表的 AES url | String | |
| groupAesUrl | trade post後分類的 AES url | String | |
| ~~productRecommendAesUrl~~ | ~~推薦產品的 AES url~~ | ~~String~~ | ~~帶入<[URI022](https://docs.google.com/spreadsheets/d/1qSanhvMOlmAs7sWO0Sph-WzuqAw-99cdyKv7sVSQU34/edit#gid=0)>的 `uri` ,同時設定`useOnlyUri`: 1~~ |
| ~~smallOrderRecommendAesUrl~~ | ~~最小訂購的 AES url~~ | ~~String~~ | ~~帶入<[URI023](https://docs.google.com/spreadsheets/d/1DOD0cXYU4WnQD3WcP6rzkZb7dKxMvfjz0ABykmzeiMU/edit#gid=0)>的 `uri` ,同時指定`useOnlyUri`: 1~~ |