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

import com.xunhong.erp.turbo.api.rbac.api.PermissionServiceI;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.PermissionCreateCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.PermissionDestroyCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.PermissionUpdateCmd;
import com.xunhong.erp.turbo.api.rbac.dto.qry.PermissionListQry;
import com.xunhong.erp.turbo.api.rbac.dto.qry.PermissionPageQry;
import com.xunhong.erp.turbo.api.rbac.dto.qry.PermissionShowQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.PermissionVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.PermissionCreateCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.PermissionDestroyCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.PermissionUpdateCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.PermissionListQryExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.PermissionPageQryExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.PermissionShowQryExe;
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 = PermissionServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class PermissionServiceImpl implements PermissionServiceI {
	private final PermissionListQryExe permissionListQryExe;
	private final PermissionShowQryExe permissionShowQryExe;
	private final PermissionPageQryExe permissionPageQryExe;
	private final PermissionCreateCmdExe permissionCreateCmdExe;
	private final PermissionUpdateCmdExe permissionUpdateCmdExe;
	private final PermissionDestroyCmdExe permissionDestroyCmdExe;

	@Override
	public List<PermissionVO> list(PermissionListQry permissionListQry) {
		return permissionListQryExe.execute(permissionListQry);
	}

	@Override
	public PageDTO<PermissionVO> page(PermissionPageQry permissionPageQry) {
		return PageDTO.of(permissionPageQryExe.execute(permissionPageQry));
	}

	@Override
	public PermissionVO create(PermissionCreateCmd permissionCreateCmd) {
		return permissionCreateCmdExe.execute(permissionCreateCmd);
	}

	@Override
	public PermissionVO show(PermissionShowQry permissionShowQry) {
		return permissionShowQryExe.execute(permissionShowQry);
	}

	@Override
	public PermissionVO update(PermissionUpdateCmd permissionUpdateCmd) {
		return permissionUpdateCmdExe.execute(permissionUpdateCmd);
	}

	@Override
	public void destroy(PermissionDestroyCmd permissionDestroyCmd) {
		permissionDestroyCmdExe.execute(permissionDestroyCmd);
	}
}
