package com.xunhong.erp.turbo.biz.app.service;

import com.xunhong.erp.turbo.api.biz.api.ProductServiceI;
import com.xunhong.erp.turbo.api.biz.dto.cmd.ProductCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.cmd.ProductDestroyCmd;
import com.xunhong.erp.turbo.api.biz.dto.cmd.ProductUpdateCmd;
import com.xunhong.erp.turbo.api.biz.dto.cmd.ProductDragCmd;
import com.xunhong.erp.turbo.api.biz.dto.qry.ProductListQry;
import com.xunhong.erp.turbo.api.biz.dto.qry.ProductPageQry;
import com.xunhong.erp.turbo.api.biz.dto.qry.ProductShowQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.ProductVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.biz.app.executor.cmd.ProductCreateCmdExe;
import com.xunhong.erp.turbo.biz.app.executor.cmd.ProductDestroyCmdExe;
import com.xunhong.erp.turbo.biz.app.executor.cmd.ProductUpdateCmdExe;
import com.xunhong.erp.turbo.biz.app.executor.query.ProductListQryExe;
import com.xunhong.erp.turbo.biz.app.executor.query.ProductPageQryExe;
import com.xunhong.erp.turbo.biz.app.executor.query.ProductShowQryExe;
import com.xunhong.erp.turbo.biz.app.executor.query.ProductDragCmdExe;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyifei
 */
@Slf4j
@Service
@DubboService(interfaceClass = ProductServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class ProductServiceImpl implements ProductServiceI {

    private final ProductCreateCmdExe productCreateCmdExe;
    private final ProductUpdateCmdExe productUpdateCmdExe;
    private final ProductPageQryExe productPageQryExe;
    private final ProductListQryExe productListQryExe;
    private final ProductShowQryExe productShowQryExe;
    private final ProductDestroyCmdExe productDestroyCmdExe;
    private final ProductDragCmdExe productDragCmdExe;

    @Override
    public ProductVO create(ProductCreateCmd productCreateCmd) {
        return productCreateCmdExe.execute(productCreateCmd);
    }

    @Override
    public PageDTO<ProductVO> page(ProductPageQry productPageQry) {
        return PageDTO.of(productPageQryExe.execute(productPageQry));
    }

    @Override
    public List<ProductVO> list(ProductListQry productListQry) {
        return productListQryExe.execute(productListQry);
    }

    @Override
    public ProductVO update(ProductUpdateCmd productUpdateCmd) {
        return productUpdateCmdExe.execute(productUpdateCmd);
    }

    @Override
    public ProductVO show(ProductShowQry productShowQry) {
        return productShowQryExe.execute(productShowQry);
    }

    @Override
    public void destroy(ProductDestroyCmd productDestroyCmd) {
        productDestroyCmdExe.execute(productDestroyCmd);
    }
    
    @Override
    public void drag(ProductDragCmd productDragCmd) {
        productDragCmdExe.execute(productDragCmd);
    }
}