package com.hfkj.service.sec.impl;

import com.hfkj.dao.SecRoleMenuRelMapper;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.entity.SecRoleMenuRelExample;
import com.hfkj.service.sec.SecRoleMenuRelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className: SecRoleMenuRelServiceImpl
 * @author: HuRui
 * @date: 2024/4/1
 **/
@Service("secRoleMenuRel")
public class SecRoleMenuRelServiceImpl implements SecRoleMenuRelService {

    @Resource
    private SecRoleMenuRelMapper secRoleMenuRelMapper;

    @Override
    public void batchAdd(List<SecRoleMenuRel> dataList) {
        secRoleMenuRelMapper.batchAdd(dataList);
    }

    @Override
    public void delete(Long relId) {
        secRoleMenuRelMapper.deleteByPrimaryKey(relId);
    }

    @Override
    public void deleteByRole(Long roleId) {
        SecRoleMenuRelExample example = new SecRoleMenuRelExample();
        example.createCriteria().andRoleIdEqualTo(roleId);
        secRoleMenuRelMapper.deleteByExample(example);
    }

    @Override
    public List<SecRoleMenuRel> getRelListByRole(Long roleId) {
        SecRoleMenuRelExample example = new SecRoleMenuRelExample();
        example.createCriteria().andRoleIdEqualTo(roleId);
        return secRoleMenuRelMapper.selectByExample(example);
    }

    @Override
    public List<SecRoleMenuRel> getRelListByMenu(Long menuId) {
        SecRoleMenuRelExample example = new SecRoleMenuRelExample();
        example.createCriteria().andMenuIdEqualTo(menuId);
        return secRoleMenuRelMapper.selectByExample(example);
    }
}
