Schema
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
상품 조회
apiType : service
상품 상세 조회
GET {{protocol}}://{{hostname}}:{{port}}/svc/product/list
{ "typeId": "api", "category": "product", "apiId": "read", "apiName": "상품 조회", "apiType": "service", "method": "GET", "parameters": [ { "parameter": "productId", "name": "상품ID", "valueType": "STRING", "required": true } ], "statistic": true, "aggregation": false, "root": { "configId": "root", "tid": "siteProduct", "type": "query", "resultType": "OBJECT", "cacheable": false, "cacheTime": 1, "allowParams": false, "orderNo": 1, "customResponse": "productReadResponse", "query": [ { "method": "matching", "field": "id", "value": "{{:productId}}" }, { "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": "matching", "field": "site", "value": "{{:_siteId}}" } ], "response": [ { "field": "id", "type": "field", "value": "" }, { "field": "name", "type": "field", "value": "" }, { "field": "siteProductSaleInfo", "type": "field", "value": "" }, { "field": "optionType", "type": "field", "value": "baseProduct.productOptionInfo.optionType" }, { "field": "productOptionCodes", "type": "field", "value": "baseProduct.productOptionInfo.productOptionCodes" }, { "field": "productOptions", "type": "field", "value": "baseProduct.productOptionInfo.productOptions" }, { "field": "productDetail", "type": "field", "value": "baseProduct.productDetail" }, { "field": "images", "type": "field", "value": "baseProduct.images" }, { "field": "videos", "type": "field", "value": "baseProduct.videos" } ] } }
@Component("productReadResponse") public class ProductReadResponse implements CustomResponse { @Autowired private ImageDisplayService imageDisplayService; @Override public List<QueryResult> execute(QueryContext queryContext, List<QueryResult> subList) { if (subList.size() == 0) return subList; QueryResult result = subList.get(0); imageDisplayService.setImages(queryContext, result); String id = JsonUtils.getStringValue(result, "id"); if (id == "") { id = JsonUtils.getStringValue(result, "siteProduct"); } SaleStatus saleStatus = new SaleStatus(id); result.put("saleStatus", saleStatus.getStatus()); subList.clear(); subList.add(result); return subList; } @Override public Map<String, Object> execute(ReadContext readContext, Map<String, Object> itemResult) { return itemResult; } }