| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.exception.ServiceException;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysRoleDept;
|
| | | import com.ruoyi.project.system.domain.SysRoleMenu;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.domain.SysUserRole;
|
| | | import com.ruoyi.project.system.domain.*;
|
| | | import com.ruoyi.project.system.mapper.SysRoleDeptMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserRoleMapper;
|
| | | import com.ruoyi.project.system.service.ISysRoleService;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import java.util.*;
|
| | |
|
| | | /**
|
| | | * 角色 业务层处理
|
| | |
| | | * @author ruoyi
|
| | | */
|
| | | @Service
|
| | | @RequiredArgsConstructor
|
| | | public class SysRoleServiceImpl implements ISysRoleService
|
| | | {
|
| | | @Autowired
|
| | | private SysRoleMapper roleMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysRoleMenuMapper roleMenuMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysUserRoleMapper userRoleMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysRoleDeptMapper roleDeptMapper;
|
| | | private final SysRoleMapper roleMapper;
|
| | | private final SysRoleMenuMapper roleMenuMapper;
|
| | | private final SysUserRoleMapper userRoleMapper;
|
| | | private final SysRoleDeptMapper roleDeptMapper;
|
| | |
|
| | | /**
|
| | | * 根据条件分页查询角色数据
|
| | |
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public String checkRoleNameUnique(SysRole role)
|
| | | public boolean checkRoleNameUnique(SysRole role)
|
| | | {
|
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
| | | SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
| | |
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public String checkRoleKeyUnique(SysRole role)
|
| | | public boolean checkRoleKeyUnique(SysRole role)
|
| | | {
|
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
| | | SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
|
| | |
| | | /**
|
| | | * 校验角色是否有数据权限
|
| | | *
|
| | | * @param roleId 角色id
|
| | | * @param roleIds 角色id
|
| | | */
|
| | | @Override
|
| | | public void checkRoleDataScope(Long roleId)
|
| | | public void checkRoleDataScope(Long... roleIds)
|
| | | {
|
| | | if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
| | | {
|
| | | SysRole role = new SysRole();
|
| | | role.setRoleId(roleId);
|
| | | List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
| | | if (StringUtils.isEmpty(roles))
|
| | | for (Long roleId : roleIds)
|
| | | {
|
| | | throw new ServiceException("没有权限访问角色数据!");
|
| | | SysRole role = new SysRole();
|
| | | role.setRoleId(roleId);
|
| | | List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
| | | if (StringUtils.isEmpty(roles))
|
| | | {
|
| | | throw new ServiceException("没有权限访问角色数据!");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|