package com.rf.psychological.menu.service.impl;

import com.rf.psychological.menu.dao.model.RoleMenuEntry;
import com.rf.psychological.menu.dao.repository.RoleMenuRepository;
import com.rf.psychological.menu.service.RoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:zzf
 * @Date:2022/7/7:15:02
 * @Description:
 */
@Service
public class RoleMenuServiceImpl implements RoleMenuService {

    @Autowired
    private RoleMenuRepository roleMenuRepository;
    /**
     * 查询 角色菜单关联关系
     *
     * @param role
     * @return
     */
    @Override
    public List<RoleMenuEntry> findByRole(String role) {
        return this.roleMenuRepository.findByRole(role);
    }

    /**
     * 查询菜单下的角色关联信息
     *
     * @param menuNo
     * @return
     */
    @Override
    public List<RoleMenuEntry> findByMenuNo(String menuNo) {
        return this.roleMenuRepository.findByMenuNo(menuNo);
    }

    @Override
    public void deleteByRoleNo(String roleNo) {
        this.roleMenuRepository.deleteByRole(roleNo);
    }

    @Override
    public void saveBatch(List<RoleMenuEntry> roleMenuEntryList) {
        this.roleMenuRepository.saveAll(roleMenuEntryList);
    }
}
