package com.tuoheng.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.system.entity.RoleMenu;
import com.tuoheng.system.mapper.RoleMenuMapper;
import com.tuoheng.system.service.IRoleMenuService;
import com.tuoheng.system.utils.ShiroUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 角色菜单关联表 服务实现类
 * </p>
 *
 * @author 拓恒
 * @since 2020-10-30
 */
@Service
public class RoleMenuServiceImpl extends BaseServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService {

    /**
     * 根据角色ID删除角色菜单关系数据
     *
     * @param roleId 角色ID
     * @return
     */
    @Override
    public boolean deleteRoleMenus(Integer roleId) {
        QueryWrapper<RoleMenu> queryWrapper = new QueryWrapper<>();
        // 租户ID
        queryWrapper.eq("tenant_id", ShiroUtils.getTenantId());
        queryWrapper.eq("role_id", roleId);
        boolean result = remove(queryWrapper);
        return result;
    }
}
