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

import com.xunhong.erp.turbo.api.infra.api.MaterialServiceI;
import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialBatchAddCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialDestroyCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialUpdateCmd;
import com.xunhong.erp.turbo.api.infra.dto.qry.MaterialPageQry;
import com.xunhong.erp.turbo.api.infra.dto.qry.MaterialShowQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.MaterialVO;
import com.xunhong.erp.turbo.api.user.dto.vo.OssTokenVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.infra.app.executor.cmd.MaterialBatchAddCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.MaterialCreateCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.MaterialDestroyCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.cmd.MaterialUpdateCmdExe;
import com.xunhong.erp.turbo.infra.app.executor.query.MaterialPageQryExe;
import com.xunhong.erp.turbo.infra.app.executor.query.MaterialShowQryExe;
import com.xunhong.erp.turbo.infra.app.executor.query.OssTokenQryExe;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyifei
 */
@Service
@DubboService(interfaceClass = MaterialServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class MaterialServiceImpl implements MaterialServiceI {
	private final OssTokenQryExe ossTokenQryExe;

	private final MaterialCreateCmdExe materialCreateCmdExe;

	private final MaterialBatchAddCmdExe materialBatchAddCmdExe;

	private final MaterialPageQryExe materialPageQryExe;
	private final MaterialShowQryExe materialShowQryExe;
	private final MaterialUpdateCmdExe materialUpdateCmdExe;
	private final MaterialDestroyCmdExe materialDestroyCmdExe;

	@Override
	public OssTokenVO ossToken() {
		return ossTokenQryExe.execute();
	}

	@Override
	public PageDTO<MaterialVO> page(MaterialPageQry materialPageQry) {
		return PageDTO.of(materialPageQryExe.execute(materialPageQry));
	}

	@Override
	public MaterialVO create(MaterialCreateCmd materialCreateCmd) {
		return materialCreateCmdExe.execute(materialCreateCmd);
	}

	@Override
	public MaterialVO show(MaterialShowQry materialShowQry) {
		return materialShowQryExe.execute(materialShowQry);
	}

	@Override
	public MaterialVO update(MaterialUpdateCmd materialUpdateCmd) {
		return materialUpdateCmdExe.execute(materialUpdateCmd);
	}

	@Override
	public void destroy(MaterialDestroyCmd materialDestroyCmd) {
		materialDestroyCmdExe.execute(materialDestroyCmd);
	}

	@Override
	public List<MaterialVO> batchCreate(MaterialBatchAddCmd materialAddCmdList) {
		return materialBatchAddCmdExe.execute(materialAddCmdList);
	}
}
