owned this note
owned this note
Published
Linked with GitHub
# URI-D-02 Offer to sell 詳細頁 API
###### tags: `CP頁` `API`
> [name=Tony Fan, Kenshi Chen]
## 內容
### 網址
- https://trading-post.taiwantrade.com/tradingPost/1342010.html
### 程式
- com/hyweb/tt/cms/front/rest/TradingPostResource.java
- #71
- com/hyweb/tt/cms/cm/webservice/BusinessPostWebService.java
- #542
### Input JSON Path
#### 規格
- path : `${TT-API網址}/trade-posts/detail/{did}/{id}`
- method : GET
- query : 無
- body : 無
#### 輸入參數說明
- did: 網別代碼
- id : 商機 ID
#### 範例
```=json
https://tt-api.taiwantrade.com/trade-posts/detail/701/1290151
```
* 參考 [URI-D-02 測試案例](https://docs.google.com/spreadsheets/d/1T0l9XRiffJqCnPEeUSNXEBTyYVXQbUWneF3mCKQkGpQ/edit#gid=1093005017)
### Output JSON Path
#### 規格
```=json
{
"code" : <code>,
"errorMsg" : <errorMsg>,
"data": {
"aid": <aid>,
"companyName": <companyName>,
"contact": <contact>,
"userEmail": <userEmail>,
"tel": <tel>,
"companyWebsite": <companyWebsite>,
"offerType": <offerType>,
"subject": <subject>,
"country": <country>,
"validDate": <validDate>,
"companyId": <companyId>,
"userTitleName": <userTitleName>,
"productDetails": <productDetails>,
"catalogId": <catalogId>,
"catalogNamePath": <catalogNamePath>,
"attach": [
{
"aid": <aid>,
"seq": <seq>,
"attachUrl": <attachUrl>,
"attachName": <attachName>
},
...
]
}
}
```
#### 輸出參數說明
TradePost輸出欄位
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- | -------- |
| code | 代碼 | int | 0表示ok |
| errorMsg | 錯誤訊息 | String | |
| aid | 商機 ID | int | N |
| subject | 商機標題 | String | N |
| contact | 發送者 | String | |
| userTitleName | 發送者稱謂 | String | |
| userEmail | 發送者Email | String | |
| tel | 發送者電話(由後臺串接,國碼+電話+分機) | String | |
| companyId | 發送者公司CID | int | N |
| companyName | 發送者公司 | String | |
| ~~address~~ | ~~發送者地址~~ | ~~String~~ | |
| companyWebsite | 發送者公司網站 | String | |
| ~~auditDate~~ | ~~商機張貼日期~~ | ~~String~~ ~~int(日期)~~ | |
| validDate | 商機有效日期 | ~~String~~ int(日期) | |
| ~~offerTypeId~~ | ~~商機類型代碼~~ | ~~int~~ | ~~N~~ |
|~~offerType~~ | ~~商機類型名稱~~ | ~~String~~ | ~~N~~ |
| country | 發送者公司註冊國家 | String | |
| productDetails | 產品描述 | String | |
| catalogId | 商機分類 ID (標準taitra) | int | N |
| catalogNamePath | 商機分類麵包屑 (標準taitra,由後臺串接,參考TradingPostResource.java #151) | String | |
| attach | 附件(參考getBusinessPostAttach) | [`附件欄位(Array Object)`](#附件欄位) | |
* offerType: 當值為Sell時顯示詳細內容
* 參考 src/main/webapp/site/tteng/xsl/page/tradingPost/offerView.xsl #237
* code
* 代碼為-999則表示找不到資料,找不到資料情況有四。
* 1.ID不匹配
* 2.審核沒有通過
* 3.有效日期過期
* 4.開始時間尚未到
##### 附件欄位
| 欄位名稱 | 欄位說明 | 型態 | 是否可為空值 |
| -------- | -------- | -------- |-------- |
| aid | 附件 ID | int | N |
| seq | 附件順序 | int | N |
| attachUrl | 附件 URL | String | |
| attachName | 附件名稱 | String | |
#### Output範例
```=json
{
"code": 0,
"errorMsg": null,
"intervalTime": null,
"data": {
"aid": 640038,
"companyName": "HYWEB TECHNOLOGY CO., LTD.",
"contact": "LiuccHywebSU",
"userEmail": "liucc@hyweb.com.tw",
"tel": "+886-23956966#2501",
"companyWebsite": "http://www.hyweb.com.tw",
"subject": "10.1 Android Tablet",
"country": "Taiwan",
"validDate": 1640880000000,
"companyId": 2,
"userTitleName": "Mr.",
"productDetails": "No deaths have been reported, but officials in the state of Tamil Nadu, of which Chennai is the capital, have issued warnings to evacuate people from low-lying areas.\r\n\r\nLocal media footage showed uprooted trees and cars submerged as water quickly rose to block roads.\r\n\r\nThis is the heaviest rainfall in the city since 2015.\r\n\r\nAlthough the city is frequently hit with heavy rains this time of the year, experts say unchecked development and bad urban planning leads to the destruction and chaos. Climate change caused by global warming has also contributed to the problem, making extreme rainfall more likely and more frequent.",
"catalogId": 1911,
"catalogNamePath": "Consumer Electronics>Mobile Phone & Tablet PC>Tablet PC",
"attach": [
{
"aid": 33104324,
"seq": 1,
"attachUrl": "//file01.ttstaging.com.tw/eb646319-b5a8-40f1-9085-7d3460ef6aec/Sample.pdf",
"attachName": "Sample.pdf"
},
{
"aid": 33104325,
"seq": 2,
"attachUrl": "//file01.ttstaging.com.tw/e6393197-20b2-4c46-a39b-5e5a3f0b7905/hyweb_newlogo2_%282%29.png",
"attachName": "hyweb_newlogo2 (2).png"
},
{
"aid": 33104326,
"seq": 3,
"attachUrl": "//file01.ttstaging.com.tw/916009d2-09b2-4abf-b527-439039fc5153/hyweb_newlogo2.png",
"attachName": "hyweb_newlogo2.png"
}
]
}
}
```
#### SQL
```=sql
--單筆商機
SELECT id, subject, user_name, user_title_code, cm.name user_title_name, user_email,
Office_Tel_Country, Office_Tel, Office_Tel_Ext, b.company_id, company_name,
business_nation_code, cm3.name country, product_description, b.catalog_id, mccc.name catalog,
buy_or_sell, company_website_url, audit_date, valid_date,
(CASE WHEN mc.name IS NOT NULL THEN mc.name|| '>'|| mcc.name|| '>'||mccc.name
WHEN mcc.name IS NOT NULL THEN mcc.name|| '>'||mccc.name
ELSE mccc.name
END )AS catalog_name_path
FROM BUSINESS_POST b
JOIN domain d ON d.did = 701 -- domain id
LEFT JOIN CODE_META_LANG cm ON cm.cid = b.user_title_code AND cm.lang_id = d.language_id
LEFT JOIN CODE_META_LANG cm3 ON cm3.cid = b.business_nation_code AND cm3.lang_id = cm.lang_id
LEFT JOIN catalog_standard ccc ON ccc.cid = b.catalog_id
LEFT JOIN multi_catalog_standard mccc ON mccc.cid = ccc.cid AND mccc.language_id = d.language_id
LEFT JOIN catalog_standard cc ON cc.cid = ccc.parent_cid
LEFT JOIN multi_catalog_standard mcc ON mcc.cid = cc.cid AND mcc.language_id = mccc.language_id
LEFT JOIN catalog_standard c ON c.cid = cc.parent_cid
LEFT JOIN multi_catalog_standard mc ON mc.cid = c.cid AND mc.language_id = mcc.language_id
WHERE id = 630136 --商機ID
;
-- 商機附件
SELECT a.aid, a.original_file_url, a.attach_name, rownum AS attach_seq
FROM BUSINESS_POST_TO_ATTACH b
JOIN ATTACH a ON a.aid = b.attach_id
WHERE business_post_id = 630136 ORDER BY aid--商機ID
;
```