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

import com.xunhong.erp.turbo.api.rbac.api.RoleServiceI;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.RoleCreateCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.RoleDestroyCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.RoleUpdateCmd;
import com.xunhong.erp.turbo.api.rbac.dto.qry.RoleListQry;
import com.xunhong.erp.turbo.api.rbac.dto.qry.RolePageQry;
import com.xunhong.erp.turbo.api.rbac.dto.qry.RoleShowQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.RoleVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.RoleCreateCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.RoleDestroyCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.RoleUpdateCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.RoleListQryExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.RolePageQryExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.RoleShowQryExe;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
@DubboService(interfaceClass = RoleServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class RoleServiceImpl implements RoleServiceI {

	private final RoleListQryExe roleListQryExe;
	private final RoleCreateCmdExe roleCreateCmdExe;
	private final RoleUpdateCmdExe roleUpdateCmdExe;
	private final RoleDestroyCmdExe roleDestroyCmdExe;
	private final RoleShowQryExe roleShowQryExe;
	private final RolePageQryExe rolePageQryExe;

	@Override
	public List<RoleVO> listRole(RoleListQry roleListQry) {
		return roleListQryExe.execute(roleListQry);
	}

	@Override
	public RoleVO createRole(RoleCreateCmd roleCreateCmd) {
		return roleCreateCmdExe.execute(roleCreateCmd);
	}

	@Override
	public RoleVO showRole(RoleShowQry roleShowQry) {
		return roleShowQryExe.execute(roleShowQry);
	}

	@Override
	public RoleVO updateRole(RoleUpdateCmd roleUpdateCmd) {
		return roleUpdateCmdExe.execute(roleUpdateCmd);
	}

	@Override
	public void destroyRole(RoleDestroyCmd roleDeleteCmd) {
		roleDestroyCmdExe.execute(roleDeleteCmd);
	}

	@Override
	public PageDTO<RoleVO> pageRole(RolePageQry rolePageQry) {
		return PageDTO.of(rolePageQryExe.execute(rolePageQry));
	}
}
