package cn.pluss.platform.menuInfo;

import cn.pluss.platform.entity.MenuInfo;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.mapper.MenuInfoMapper;
import cn.pluss.platform.shiro.UserService;
import cn.pluss.platform.util.tree.TreeUtils;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;
import java.util.Map;

public interface MenuInfoService extends IService<MenuInfo> {

    List<MenuInfo> getMenuTree(MenuInfo menuInfo);

    List<MenuInfo> getRoleConfigMenuTree(MenuInfo menuInfo, String roleId);

    /**
     * 清理父节点的check状态
     * @param result    结果树
     */
    default void clear(List<MenuInfo> result) {
        for (MenuInfo menuInfo : result) {
            List<MenuInfo> children = menuInfo.getChildren();
            if (children != null && children.size() > 0) {
                menuInfo.setChecked(0);
                clear(children);
            }
        }
    }

    MenuInfo queryMenuInfo(MenuInfo menuInfo);

    default List<MenuInfo> queryMenuInfoList(MenuInfo menuInfo) {
        return ((MenuInfoMapper) getBaseMapper()).queryMenuInfoList(menuInfo);
    }

    default List<MenuInfo> queryRoleMenuInfoList(MenuInfo menuInfo, String roleId) {
        return ((MenuInfoMapper) getBaseMapper()).queryRoleMenuInfoList(menuInfo, roleId);
    }

    Integer saveMenuInfo(MenuInfo menuInfo);

    void updateMenuInfo(MenuInfo menuInfo);

    void deleteMenuInfo(MenuInfo menuInfo);

    List<MenuInfo> queryMenuInfoPage(Map map);

    Integer queryMenuInfoPageCount(Map map);

    List<MenuInfo> getPermissionNames(String loginName);
	
	List<MenuInfo> queryPermitMenuInfoById(Map map);
	
	List<MenuInfo> queryMenuInfoListOrderById(MenuInfo menuInfo);
	
	List<MenuInfo> queryMenuInfoByRoleId(Map map);
}

