| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.SysRoleDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.mapper.SysUserRoleMapper; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.SpringUtils; |
| | |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.SysRoleDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.mapper.SysUserRoleMapper; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | 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; |
| | | |
| | | /** |
| | | * 角色 业务层处理 |
| | |
| | | public int updateRole(SysRole role) |
| | | { |
| | | // 修改角色信息 |
| | | // roleMapper.updateRole(role); |
| | | // roleMapper.updateRole(role); |
| | | // 删除角色与菜单关联 |
| | | // roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); |
| | | roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); |
| | | return roleMapper.updateRole(role); |
| | | } |
| | | |
| | |
| | | // 新增用户与角色管理 |
| | | List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); |
| | | Long[] menuIds = role.getMenuIds(); |
| | | // List<Long> longs = Arrays.asList(menuIds); |
| | | List<Long> longs = new ArrayList<>(); |
| | | for (Long menuId : menuIds) { |
| | | longs.add(menuId); |
| | | } |
| | | if(!longs.contains(1061L)){ |
| | | longs.add(1061L); |
| | | longs.add(1062L); |
| | | longs.add(1065L); |
| | | longs.add(1073L); |
| | | longs.add(1161L); |
| | | longs.add(1203L); |
| | | } |
| | | |
| | | List<Long> longs = Lists.newArrayList(menuIds); |
| | | for (Long menuId : longs) |
| | | { |
| | | SysRoleMenu rm = new SysRoleMenu(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<SysRole> isExitUpdate(String roleName, Long roleId,Integer companyId) { |
| | | return roleMapper.isExitUpdate(roleName,roleId,companyId); |
| | | public List<SysRole> isExitUpdate(String roleName, Long roleId) { |
| | | return roleMapper.isExitUpdate(roleName, roleId); |
| | | } |
| | | |
| | | @Override |
| | | public void removeRole(Long id) { |
| | | SysRole sysRole = baseMapper.selectRoleById(id); |
| | | Long count = userRoleMapper.selectCount( |
| | | Wrappers.lambdaQuery(SysUserRole.class).eq(SysUserRole::getRoleId, id)); |
| | | if (count > 0) { |
| | | throw new ServiceException("角色已绑定账号,不能删除"); |
| | | } |
| | | if (StringUtils.isNull(sysRole)) { |
| | | throw new ServiceException("角色不存在"); |
| | | } |
| | | sysRole.setDelFlag("2"); |
| | | this.updateRole(sysRole); |
| | | } |
| | | } |