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

import com.xunhong.erp.turbo.api.infra.api.DictionaryServiceI;
import com.xunhong.erp.turbo.api.infra.dto.cmd.DictionaryCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.DictionaryDestroyCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.DictionaryUpdateCmd;
import com.xunhong.erp.turbo.api.infra.dto.qry.DictionaryListQry;
import com.xunhong.erp.turbo.api.infra.dto.qry.DictionaryPageQry;
import com.xunhong.erp.turbo.api.infra.dto.qry.DictionaryShowQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.DictionaryVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.infra.app.executor.cmd.DictionaryCreateCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.DictionaryDestroyCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.DictionaryUpdateCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.query.DictionaryListQryExe;
import com.xunhong.erp.turbo.infra.app.executor.query.DictionaryPageQryExe;
import com.xunhong.erp.turbo.infra.app.executor.query.DictionaryShowQryExe;
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 = DictionaryServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class DictionaryServiceImpl implements DictionaryServiceI {

	private final DictionaryCreateCmdExe dictionaryCreateCmdExe;
	private final DictionaryUpdateCmdExe dictionaryUpdateCmdExe;
	private final DictionaryPageQryExe dictionaryPageQryExe;
	private final DictionaryListQryExe dictionaryListQryExe;
	private final DictionaryShowQryExe dictionaryShowQryExe;
	private final DictionaryDestroyCmdExe dictionaryDestroyCmdExe;

	@Override
	public DictionaryVO create(DictionaryCreateCmd dictionaryCreateCmd) {
		return dictionaryCreateCmdExe.execute(dictionaryCreateCmd);
	}

	@Override
	public PageDTO<DictionaryVO> page(DictionaryPageQry dictionaryPageQry) {
		return PageDTO.of(dictionaryPageQryExe.execute(dictionaryPageQry));
	}

	@Override
	public List<DictionaryVO> list(DictionaryListQry dictionaryListQry) {
		return dictionaryListQryExe.execute(dictionaryListQry);
	}

	@Override
	public DictionaryVO update(DictionaryUpdateCmd dictionaryUpdateCmd) {
		return dictionaryUpdateCmdExe.execute(dictionaryUpdateCmd);
	}

	@Override
	public DictionaryVO show(DictionaryShowQry dictionaryShowQry) {
		return dictionaryShowQryExe.execute(dictionaryShowQry);
	}

	@Override
	public void destroy(DictionaryDestroyCmd dictionaryDestroyCmd) {
		dictionaryDestroyCmdExe.execute(dictionaryDestroyCmd);
	}
}

