package com.tuoheng.admin.service.system.role;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.tuoheng.admin.entity.domain.OpRolePermission;
import com.tuoheng.admin.mapper.OpRolePermissionMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author ChengWang
 * @Date 2022/12/26
 */
@Service
@Slf4j
public class OpRolePermissionServiceImpl implements OpRolePermissionService {

    @Autowired
    private OpRolePermissionMapper opRolePermissionMapper;
    /**
     * 根据角色ID删除角色菜单关系数据
     *
     * @param roleId 角色ID
     * @return
     */
    @Override
    public boolean deleteRolePermissions(Integer roleId) {
        QueryWrapper<OpRolePermission> queryWrapper = new QueryWrapper<>();
        //queryWrapper.eq("tenant_id", ShiroUtils.getTenantId());
        queryWrapper.eq("role_id", roleId);
        boolean result = SqlHelper.retBool(opRolePermissionMapper.delete(queryWrapper));
        return result;
    }
}
