package com.ruoyi.api.service.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.ruoyi.api.constant.yz.ApiEnum;
import com.ruoyi.api.downstream.YzResult;
import com.ruoyi.api.fake.PushProductFake;
import com.ruoyi.api.pojo.bo.ProductByIdsBO;
import com.ruoyi.api.pojo.bo.ProductsBO;
import com.ruoyi.api.pojo.bo.ProductsSkusBO;
import com.ruoyi.api.pojo.bo.ProductsListBO;
import com.ruoyi.api.service.IProductService;
import com.ruoyi.api.utils.YzResultProcessingUtil;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class ProductServiceImpl implements IProductService {

    @Override
    public YzResult pushProduct() throws JsonProcessingException {
        // TODO:没有第三方供应链，伪造测试数据
        ProductsBO productsBO = PushProductFake.pushProduct();
        return YzResultProcessingUtil.getYzResult(ApiEnum.PUSH_PRODUCT, productsBO);
    }

    @Override
    public YzResult updateCloudProduct() throws JsonProcessingException {
        // TODO:没有第三方供应链，伪造测试数据
        ProductsBO productsBO = PushProductFake.updateCloudProduct();
        return YzResultProcessingUtil.getYzResult(ApiEnum.UPDATE_CLOUD_PRODUCT, productsBO);
    }

    @Override
    public YzResult updateCloudSku() throws JsonProcessingException {
        // TODO:没有第三方供应链，伪造测试数据
        ProductsSkusBO productsSkusBO = PushProductFake.updateCloudSku();
        return YzResultProcessingUtil.getYzResult(ApiEnum.UPDATE_CLOUD_SKU, productsSkusBO);
    }

    @Override
    public YzResult displayProductByIds() throws JsonProcessingException {
        // TODO:没有第三方供应链，伪造测试数据
        ProductByIdsBO productByIdsBO = PushProductFake.displayProductByIds();
        return YzResultProcessingUtil.getYzResult(ApiEnum.DISPLAY_PRODUCT_BY_IDS, productByIdsBO);
    }

    @Override
    public YzResult findProduct() throws JsonProcessingException {
        // TODO:没有第三方供应链，伪造测试数据
        Map<String, Integer> map = new HashMap<>();
        map.put("id", 398);
        return YzResultProcessingUtil.getYzResult(ApiEnum.FIND_PRODUCT, map);
    }

    @Override
    public YzResult deleteProduct() throws JsonProcessingException {
        // TODO:没有第三方供应链，伪造测试数据
        Map<String, Integer> map = new HashMap<>();
        map.put("id", 398);
        return YzResultProcessingUtil.getYzResult(ApiEnum.DELETE_PRODUCT, map);
    }


    @Override
    public YzResult getProductsList() throws JsonProcessingException {
        ProductsListBO productsListBO = PushProductFake.getProductsList();
        return YzResultProcessingUtil.getYzResult(ApiEnum.GET_ClOUD_PRODUCT_LIST, productsListBO);
    }

}
