Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Schema

  • product

  • siteProduct

API

  • 상품 리스트

  • 상품 조회

Postman collection

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

View file
nameSchema, API 리뷰 (상품 리스트, 조회).postman_collection.json

상품 리스트

  • apiType : service

  • 카테고리 별 상품 리스트

...

Code Block
@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

Expand
titleSUCCESS
Code Block
{
    "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

  • 상품 상세 조회

...

Code Block
@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;
    }
}

Result

Expand
titleNot Found
Code Block
{
    "result": "404",
    "resultMessage": "Not Found"
}

...