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

import com.xunhong.erp.turbo.api.infra.api.CategoryServiceI;
import com.xunhong.erp.turbo.api.infra.dto.cmd.CategoryCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.CategoryDestroyCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.CategoryUpdateCmd;
import com.xunhong.erp.turbo.api.infra.dto.qry.CategoryPageQry;
import com.xunhong.erp.turbo.api.infra.dto.qry.CategoryShowQry;
import com.xunhong.erp.turbo.api.infra.dto.qry.CategoryTreeQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.CategoryVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.infra.app.executor.cmd.CategoryCreateCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.CategoryDestroyCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.CategoryUpdateCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.query.CategoryListQryExe;
import com.xunhong.erp.turbo.infra.app.executor.query.CategoryPageQryExe;
import com.xunhong.erp.turbo.infra.app.executor.query.CategoryShowQryExe;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@DubboService(interfaceClass = CategoryServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class CategoryServiceImpl implements CategoryServiceI {
	private final CategoryListQryExe categoryListQryExe;
	private final CategoryCreateCmdExe categoryCreateCmdExe;
	private final CategoryUpdateCmdExe categoryUpdateCmdExe;
	private final CategoryShowQryExe categoryShowQryExe;
	private final CategoryDestroyCmdExe categoryDestroyCmdExe;
	private final CategoryPageQryExe categoryPageQryExe;

	@Override
	public PageDTO<CategoryVO> page(CategoryPageQry categoryPageQry) {
		return PageDTO.of(categoryPageQryExe.execute(categoryPageQry));
	}

	@Override
	public List<CategoryVO> list(CategoryTreeQry categoryTreeQry) {
		return categoryListQryExe.execute(categoryTreeQry);
	}

	@Override
	public CategoryVO create(CategoryCreateCmd categoryCreateCmd) {
		return categoryCreateCmdExe.execute(categoryCreateCmd);
	}

	@Override
	public CategoryVO update(CategoryUpdateCmd categoryUpdateCmd) {
		return categoryUpdateCmdExe.execute(categoryUpdateCmd);
	}

	@Override
	public CategoryVO show(CategoryShowQry categoryShowQry) {
		return categoryShowQryExe.execute(categoryShowQry);
	}

	@Override
	public void destroy(CategoryDestroyCmd categoryDestroyCmd) {
		categoryDestroyCmdExe.execute(categoryDestroyCmd);
	}
}
