update
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -20,6 +19,7 @@ import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.modules.redis.client.JeecgRedisClient;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
@@ -69,9 +69,9 @@ public class SysRoleController {
|
||||
@Autowired
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
private BaseCommonService baseCommonService;
|
||||
@Autowired
|
||||
private JeecgRedisClient jeecgRedisClient;
|
||||
private JeecgRedisClient jeecgRedisClient;
|
||||
|
||||
/**
|
||||
* 分页列表查询 【系统角色,不做租户隔离】
|
||||
@@ -89,12 +89,16 @@ public class SysRoleController {
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
|
||||
//QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
|
||||
//IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper);
|
||||
Page<SysRole> page = new Page<SysRole>(pageNo, pageSize);
|
||||
page.addOrder(OrderItem.desc("create_time"));
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
// 自定义duoXuan字段的查询规则为:LIKE_WITH_OR
|
||||
customeRuleMap.put("roleName", QueryRuleEnum.LIKE);
|
||||
customeRuleMap.put("roleCode", QueryRuleEnum.LIKE);
|
||||
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap(), customeRuleMap);
|
||||
IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper);
|
||||
//换成不做租户隔离的方法,实际上还是存在缺陷(缺陷:如果开启租户隔离,虽然能看到其他租户下的角色,编辑会提示报错)
|
||||
IPage<SysRole> pageList = sysRoleService.listAllSysRole(page, role);
|
||||
//IPage<SysRole> pageList = sysRoleService.listAllSysRole(page, role);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
@@ -179,7 +183,8 @@ public class SysRoleController {
|
||||
Integer tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
String username = "admin";
|
||||
if (!tenantId.equals(role.getTenantId()) && !username.equals(sysUser.getUsername())) {
|
||||
baseCommonService.addLog("未经授权,修改非本租户下的角色ID:" + role.getId() + ",操作人:" + sysUser.getUsername(), CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_3);
|
||||
baseCommonService.addLog("未经授权,修改非本租户下的角色ID:" + role.getId() + ",操作人:" + sysUser.getUsername(),
|
||||
CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_3);
|
||||
return Result.error("修改角色失败,当前角色不在此租户中。");
|
||||
}
|
||||
}
|
||||
@@ -210,7 +215,8 @@ public class SysRoleController {
|
||||
Long getRoleCount = sysRoleService.getRoleCountByTenantId(id, tenantId);
|
||||
String username = "admin";
|
||||
if (getRoleCount == 0 && !username.equals(sysUser.getUsername())) {
|
||||
baseCommonService.addLog("未经授权,删除非本租户下的角色ID:" + id + ",操作人:" + sysUser.getUsername(), CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_4);
|
||||
baseCommonService.addLog("未经授权,删除非本租户下的角色ID:" + id + ",操作人:" + sysUser.getUsername(),
|
||||
CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_4);
|
||||
return Result.error("删除角色失败,删除角色不属于登录租户!");
|
||||
}
|
||||
}
|
||||
@@ -250,7 +256,8 @@ public class SysRoleController {
|
||||
Long getRoleCount = sysRoleService.getRoleCountByTenantId(id, tenantId);
|
||||
//如果存在角色id为0,即不存在,则删除角色
|
||||
if (getRoleCount == 0 && !username.equals(sysUser.getUsername())) {
|
||||
baseCommonService.addLog("未经授权,删除非本租户下的角色ID:" + id + ",操作人:" + sysUser.getUsername(), CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_4);
|
||||
baseCommonService.addLog("未经授权,删除非本租户下的角色ID:" + id + ",操作人:" + sysUser.getUsername(),
|
||||
CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_4);
|
||||
return Result.error("批量删除角色失败,存在角色不在此租户中,禁止批量删除");
|
||||
}
|
||||
}
|
||||
@@ -485,7 +492,6 @@ public class SysRoleController {
|
||||
return Result.ok("保存成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户角色授权功能,查询菜单权限树
|
||||
*
|
||||
@@ -523,7 +529,8 @@ public class SysRoleController {
|
||||
private void getTreeModelList(List<TreeModel> treeList, List<SysPermission> metaList, TreeModel temp) {
|
||||
for (SysPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(), permission.getRuleFlag(), permission.isLeaf());
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(), permission.getRuleFlag(),
|
||||
permission.isLeaf());
|
||||
if (temp == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if (!tree.getIsLeaf()) {
|
||||
|
||||
Reference in New Issue
Block a user