|
@@ -5,6 +5,8 @@ import java.util.Arrays;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
+
|
|
|
|
|
+import com.ruoyi.common.utils.SM4Util;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -45,6 +47,9 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SysRoleDeptMapper roleDeptMapper;
|
|
private SysRoleDeptMapper roleDeptMapper;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SM4Util sm4Util;
|
|
|
/**
|
|
/**
|
|
|
* 根据条件分页查询角色数据
|
|
* 根据条件分页查询角色数据
|
|
|
*
|
|
*
|
|
@@ -55,7 +60,11 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@DataScope(deptAlias = "d")
|
|
@DataScope(deptAlias = "d")
|
|
|
public List<SysRole> selectRoleList(SysRole role)
|
|
public List<SysRole> selectRoleList(SysRole role)
|
|
|
{
|
|
{
|
|
|
- return roleMapper.selectRoleList(role);
|
|
|
|
|
|
|
+ List<SysRole> sysRoles = roleMapper.selectRoleList(role);
|
|
|
|
|
+ sysRoles.forEach( p ->{
|
|
|
|
|
+ p.setRoleKey(sm4Util.decrypt(p.getRoleKey()));
|
|
|
|
|
+ });
|
|
|
|
|
+ return sysRoles;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -68,6 +77,9 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
public List<SysRole> selectRolesByUserId(Long userId)
|
|
public List<SysRole> selectRolesByUserId(Long userId)
|
|
|
{
|
|
{
|
|
|
List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
|
|
List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
|
|
|
|
|
+ userRoles.forEach( p ->{
|
|
|
|
|
+ p.setRoleKey(sm4Util.decrypt(p.getRoleKey()));
|
|
|
|
|
+ });
|
|
|
List<SysRole> roles = selectRoleAll();
|
|
List<SysRole> roles = selectRoleAll();
|
|
|
for (SysRole role : roles)
|
|
for (SysRole role : roles)
|
|
|
{
|
|
{
|
|
@@ -93,6 +105,9 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
public Set<String> selectRolePermissionByUserId(Long userId)
|
|
public Set<String> selectRolePermissionByUserId(Long userId)
|
|
|
{
|
|
{
|
|
|
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
|
|
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
|
|
|
|
|
+ perms.forEach( p ->{
|
|
|
|
|
+ p.setRoleKey(sm4Util.decrypt(p.getRoleKey()));
|
|
|
|
|
+ });
|
|
|
Set<String> permsSet = new HashSet<>();
|
|
Set<String> permsSet = new HashSet<>();
|
|
|
for (SysRole perm : perms)
|
|
for (SysRole perm : perms)
|
|
|
{
|
|
{
|
|
@@ -136,7 +151,9 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@Override
|
|
@Override
|
|
|
public SysRole selectRoleById(Long roleId)
|
|
public SysRole selectRoleById(Long roleId)
|
|
|
{
|
|
{
|
|
|
- return roleMapper.selectRoleById(roleId);
|
|
|
|
|
|
|
+ SysRole sysRole = roleMapper.selectRoleById(roleId);
|
|
|
|
|
+ sysRole.setRoleKey(sm4Util.decrypt(sysRole.getRoleKey()));
|
|
|
|
|
+ return sysRole;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -150,6 +167,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
{
|
|
{
|
|
|
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
|
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
|
|
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
|
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
|
|
|
|
+ info.setRoleKey(sm4Util.decrypt(info.getRoleKey()));
|
|
|
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
|
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
|
|
{
|
|
{
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
return UserConstants.NOT_UNIQUE;
|
|
@@ -168,6 +186,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
{
|
|
{
|
|
|
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
|
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
|
|
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
|
|
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
|
|
|
|
|
+ info.setRoleKey(sm4Util.decrypt(info.getRoleKey()));
|
|
|
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
|
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
|
|
{
|
|
{
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
return UserConstants.NOT_UNIQUE;
|
|
@@ -234,6 +253,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public int insertRole(SysRole role)
|
|
public int insertRole(SysRole role)
|
|
|
{
|
|
{
|
|
|
|
|
+ role.setRoleKey(sm4Util.encrypt(role.getRoleKey()));
|
|
|
// 新增角色信息
|
|
// 新增角色信息
|
|
|
roleMapper.insertRole(role);
|
|
roleMapper.insertRole(role);
|
|
|
return insertRoleMenu(role);
|
|
return insertRoleMenu(role);
|
|
@@ -249,6 +269,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public int updateRole(SysRole role)
|
|
public int updateRole(SysRole role)
|
|
|
{
|
|
{
|
|
|
|
|
+ role.setRoleKey(sm4Util.encrypt(role.getRoleKey()));
|
|
|
// 修改角色信息
|
|
// 修改角色信息
|
|
|
roleMapper.updateRole(role);
|
|
roleMapper.updateRole(role);
|
|
|
// 删除角色与菜单关联
|
|
// 删除角色与菜单关联
|
|
@@ -265,6 +286,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@Override
|
|
@Override
|
|
|
public int updateRoleStatus(SysRole role)
|
|
public int updateRoleStatus(SysRole role)
|
|
|
{
|
|
{
|
|
|
|
|
+ role.setRoleKey(sm4Util.encrypt(role.getRoleKey()));
|
|
|
return roleMapper.updateRole(role);
|
|
return roleMapper.updateRole(role);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -278,6 +300,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public int authDataScope(SysRole role)
|
|
public int authDataScope(SysRole role)
|
|
|
{
|
|
{
|
|
|
|
|
+ role.setRoleKey(sm4Util.encrypt(role.getRoleKey()));
|
|
|
// 修改角色信息
|
|
// 修改角色信息
|
|
|
roleMapper.updateRole(role);
|
|
roleMapper.updateRole(role);
|
|
|
// 删除角色与部门关联
|
|
// 删除角色与部门关联
|