[API 리뷰] 상품 리스트, 조회

 

Schema

  • product

  • siteProduct

API

  • 상품 리스트

  • 상품 조회

 

Postman collection

Schema, API 리뷰 (상품 리스트, 조회).postman_collection.json

상품 리스트

  • apiType : service

  • 카테고리 별 상품 리스트

GET {{protocol}}://{{hostname}}:{{port}}/svc/product/list

{ "typeId": "api", "category": "product", "apiId": "list", "apiName": "Product List", "apiType": "service", "method": "GET", "parameters": [ { "parameter": "categoryId", "name": "카테고리아이디", "valueType": "STRING", "required": false }, { "parameter": "priceRange", "name": "가격 범위", "valueType": "STRING", "required": false }, { "parameter": "brand", "name": "브랜드", "valueType": "STRING", "required": false }, { "parameter": "filter", "name": "검색필터", "valueType": "STRING", "required": false } ], "statistic": true, "aggregation": false, "root": { "configId": "root", "tid": "siteProduct", "type": "query", "allowParams": false, "orderNo": 1, "cacheable": false, "cacheTime": 60, "customResponse": "productListResponse", "query": [ { "method": "matching", "field": "site", "value": "{{:_siteId}}" }, { "method": "matching", "field": "approvalStatus", "value": "approval" }, { "method": "matching", "field": "saleStatus", "value": "selling" }, { "method": "matching", "field": "exposure", "value": "true" }, { "method": "matching", "field": "deleted", "value": "false" }, { "method": "sorting", "value": "{{:sorting}},id desc" }, { "method": "page", "value": "{{:page}}" }, { "method": "pageSize", "value": "{{:pageSize}}" }, { "method": "matching", "field": "siteCategoriesIdPath", "value": "{{:categoryId}}" }, { "method": "fromto", "field": "siteProductSaleInfo.{{:decode(_deviceType,'mobile','discountSalePriceMobile','discountSalePrice')}}", "value": "{{:priceRange}}" }, { "method": "matching", "field": "baseProduct.productDetail.brand", "value": "{{:brand}}" }, { "method": "referenceJoin", "field": "baseProduct", "value": "{{:getQueryString(filter,'matching','productAttrValues')}}" } ], "response": [ { "field": "id", "type": "field", "value": "" }, { "field": "name", "type": "field", "value": "" }, { "field": "siteCategories", "type": "field", "value": "" }, { "field": "siteProductSaleInfo", "type": "field", "value": "" }, { "field": "images", "type": "field", "value": "baseProduct.images" }, { "field": "created", "type": "field", "value": "baseProduct.created" } ] } }
@Component("productListResponse") public class ProductListResponse implements CustomResponse { @Override public List<QueryResult> execute(QueryContext queryContext, List<QueryResult> subList) { if (subList.size() == 0) return subList; for (QueryResult result : subList) { if (result.get("siteProduct") != null) { Reference reference = (Reference) result.get("siteProduct"); String id = (String) reference.getValue(); SaleStatus saleStatus = new SaleStatus(id); result.put("saleStatus", saleStatus.getStatus()); result.put("id", id); result.remove("siteProduct"); } if (result.get("images") == null) { continue; } List<Map<String, Object>> images = (List<Map<String, Object>>) result.get("images"); for (Map<String, Object> image : images) { if (image.get("imageType") == null) { continue; } Code imageType = (Code) image.get("imageType"); if (StringUtils.equals(String.valueOf(imageType.getValue()), "representative")) { result.put("image", image.get("file")); result.remove("images"); } } } return subList; } @Override public Map<String, Object> execute(ReadContext readContext, Map<String, Object> itemResult) { return itemResult; } }

 

Result

{ "result": "200", "resultMessage": "SUCCESS", "totalCount": 15, "resultCount": 15, "pageSize": 20, "pageCount": 1, "currentPage": 1, "items": [ { "id": 2032456031, "name": "윈도우핏 에어컨 (17 ㎡)", "siteCategories": [ { "value": "947", "label": "홈멀티 에어컨", "refId": "947" } ], "siteProductSaleInfo": { "id": "2144595594", "label": "", "supplyPrice": 679200, "salePrice": 849000, "useDiscount": false, "discountSalePrice": 849000, "discountSalePriceMobile": 849000, "stockQuantity": 999, "minOrderQuantity": 1, "maxOrderType": { "value": "unlimited", "label": "무제한" } }, "created": "2021-06-15 20:04:18", "image": "http://local.i-on.net:8080/productImage/file/202106/15/1c69743a-a108-4b7c-9a7a-70f22f89e54d.png/ed67de12-0d04-4d85-890e-fb4bcd900bb2.png" }, { "id": 1503873680, "name": "무풍에어컨 갤러리 (56.9 ㎡)", "siteCategories": [ { "value": "947", "label": "홈멀티 에어컨", "refId": "947" } ], "siteProductSaleInfo": { "id": "856353151", "label": "", "supplyPrice": 1719200, "salePrice": 2149000, "useDiscount": false, "discountSalePrice": 2149000, "discountSalePriceMobile": 2149000, "stockQuantity": 999, "minOrderQuantity": 1, "maxOrderType": { "value": "unlimited", "label": "무제한" } }, "created": "2021-06-15 20:04:17", "image": "http://local.i-on.net:8080/productImage/file/202106/15/ecf53fc2-1d5d-45a3-a557-c66706794c82.png/32e49215-68b4-4710-814c-466e5c4023d0.png" } ] }

 

 

 

상품 조회

  • apiType : service

  • 상품 상세 조회

GET {{protocol}}://{{hostname}}:{{port}}/svc/product/list

 

Result