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

import cn.hutool.core.lang.tree.Tree;
import com.xunhong.erp.turbo.api.rbac.api.MenuServiceI;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.MenuCreateCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.MenuDestroyCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.MenuDragCmd;
import com.xunhong.erp.turbo.api.rbac.dto.cmd.MenuUpdateCmd;
import com.xunhong.erp.turbo.api.rbac.dto.qry.MenuListQry;
import com.xunhong.erp.turbo.api.rbac.dto.qry.MenuShowQry;
import com.xunhong.erp.turbo.api.rbac.dto.qry.MenuTreeQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.MenuVO;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.MenuCreateCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.MenuDestroyCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.cmd.MenuUpdateCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.MenuDragCmdExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.MenuListQryExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.MenuShowQryExe;
import com.xunhong.erp.turbo.rbac.app.executor.query.MenuTreeQryExe;
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
 * @author shenyifei
 */
@Slf4j
@Service
@DubboService(interfaceClass = MenuServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class MenuServiceImpl implements MenuServiceI {

	private final MenuTreeQryExe menuTreeQryExe;
	private final MenuCreateCmdExe menuCreateCmdExe;
	private final MenuUpdateCmdExe menuUpdateCmdExe;
	private final MenuShowQryExe menuShowQryExe;
	private final MenuDestroyCmdExe menuDestroyCmdExe;
	private final MenuListQryExe menuListQryExe;
	private final MenuDragCmdExe menuDragCmdExe;

	@Override
	public List<Tree<Long>> tree(MenuTreeQry menuTreeQry) {
		return menuTreeQryExe.execute(menuTreeQry);
	}

	@Override
	public MenuVO create(MenuCreateCmd menuCreateCmd) {
		return menuCreateCmdExe.execute(menuCreateCmd);
	}

	@Override
	public MenuVO show(MenuShowQry menuShowQry) {
		return menuShowQryExe.execute(menuShowQry);
	}

	@Override
	public MenuVO update(MenuUpdateCmd menuUpdateCmd) {
		return menuUpdateCmdExe.execute(menuUpdateCmd);
	}

	@Override
	public void destroy(MenuDestroyCmd menuDestroyCmd) {
		menuDestroyCmdExe.execute(menuDestroyCmd);
	}

	@Override
	public List<MenuVO> list(MenuListQry menuListQry) {
		return menuListQryExe.execute(menuListQry);
	}

	@Override
	public void drag(MenuDragCmd menuDragCmd) {
		menuDragCmdExe.execute(menuDragCmd);
	}
}
