package com.qiaoba.module.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.qiaoba.api.system.entity.SysRoleMenu;
import com.qiaoba.module.system.mapper.SysRoleMenuMapper;
import com.qiaoba.module.system.service.SysRoleMenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色菜单关联 服务层实现
 *
 * @author ailanyin
 * @version 1.0
 * @since 2023/5/9 10:08
 */
@Service
@RequiredArgsConstructor
public class SysRoleMenuServiceImpl implements SysRoleMenuService {

    private final SysRoleMenuMapper sysRoleMenuMapper;

    @Override
    public void insertBatch(List<SysRoleMenu> list) {
        Db.saveBatch(list);
    }

    @Override
    public void deleteByRoleIds(List<String> ids) {
        sysRoleMenuMapper.deleteByRoleIds(ids);
    }

    @Override
    public void deleteByRoleId(String roleId) {
        QueryWrapper<SysRoleMenu> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SysRoleMenu::getRoleId, roleId);
        sysRoleMenuMapper.delete(wrapper);
    }

}
