org.jeecg.modules.system.entity.SysRolePermission Java Examples

The following examples show how to use org.jeecg.modules.system.entity.SysRolePermission. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("roleId") String roleId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.isNotNull(SysRolePermission::getDataRuleIds)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			//return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysRolePermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #2
Source File: SysRolePermissionServiceImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
	List<String> add = getDiff(lastPermissionIds,permissionIds);
	if(add!=null && add.size()>0) {
		List<SysRolePermission> list = new ArrayList<SysRolePermission>();
		for (String p : add) {
			if(oConvertUtils.isNotEmpty(p)) {
				SysRolePermission rolepms = new SysRolePermission(roleId, p);
				list.add(rolepms);
			}
		}
		this.saveBatch(list);
	}
	
	List<String> delete = getDiff(permissionIds,lastPermissionIds);
	if(delete!=null && delete.size()>0) {
		for (String permissionId : delete) {
			this.remove(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId).eq(SysRolePermission::getPermissionId, permissionId));
		}
	}
}
 
Example #3
Source File: SysRoleController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 保存数据规则至角色菜单关联表
 */
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
	try {
		String permissionId = jsonObject.getString("permissionId");
		String roleId = jsonObject.getString("roleId");
		String dataRuleIds = jsonObject.getString("dataRuleIds");
		log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			return Result.error("请先保存角色菜单权限!");
		}else {
			sysRolePermission.setDataRuleIds(dataRuleIds);
			this.sysRolePermissionService.updateById(sysRolePermission);
		}
	} catch (Exception e) {
		log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
		return Result.error("保存失败");
	}
	return Result.ok("保存成功!");
}
 
Example #4
Source File: SysRoleController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("roleId") String roleId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.isNotNull(SysRolePermission::getDataRuleIds)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			//return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysRolePermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #5
Source File: SysRolePermissionServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
	List<String> add = getDiff(lastPermissionIds,permissionIds);
	if(add!=null && add.size()>0) {
		List<SysRolePermission> list = new ArrayList<SysRolePermission>();
		for (String p : add) {
			if(oConvertUtils.isNotEmpty(p)) {
				SysRolePermission rolepms = new SysRolePermission(roleId, p);
				list.add(rolepms);
			}
		}
		this.saveBatch(list);
	}
	
	List<String> delete = getDiff(permissionIds,lastPermissionIds);
	if(delete!=null && delete.size()>0) {
		for (String permissionId : delete) {
			this.remove(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId).eq(SysRolePermission::getPermissionId, permissionId));
		}
	}
}
 
Example #6
Source File: SysRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 保存数据规则至角色菜单关联表
 */
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
	try {
		String permissionId = jsonObject.getString("permissionId");
		String roleId = jsonObject.getString("roleId");
		String dataRuleIds = jsonObject.getString("dataRuleIds");
		log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			return Result.error("请先保存角色菜单权限!");
		}else {
			sysRolePermission.setDataRuleIds(dataRuleIds);
			this.sysRolePermissionService.updateById(sysRolePermission);
		}
	} catch (Exception e) {
		log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
		return Result.error("保存失败");
	}
	return Result.ok("保存成功!");
}
 
Example #7
Source File: SysRoleController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("roleId") String roleId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.isNotNull(SysRolePermission::getDataRuleIds)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			//return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysRolePermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #8
Source File: SysRolePermissionServiceImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
	List<String> add = getDiff(lastPermissionIds,permissionIds);
	if(add!=null && add.size()>0) {
		List<SysRolePermission> list = new ArrayList<SysRolePermission>();
		for (String p : add) {
			if(oConvertUtils.isNotEmpty(p)) {
				SysRolePermission rolepms = new SysRolePermission(roleId, p);
				list.add(rolepms);
			}
		}
		this.saveBatch(list);
	}
	
	List<String> delete = getDiff(permissionIds,lastPermissionIds);
	if(delete!=null && delete.size()>0) {
		for (String permissionId : delete) {
			this.remove(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId).eq(SysRolePermission::getPermissionId, permissionId));
		}
	}
}
 
Example #9
Source File: SysRoleController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 保存数据规则至角色菜单关联表
 */
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
	try {
		String permissionId = jsonObject.getString("permissionId");
		String roleId = jsonObject.getString("roleId");
		String dataRuleIds = jsonObject.getString("dataRuleIds");
		log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			return Result.error("请先保存角色菜单权限!");
		}else {
			sysRolePermission.setDataRuleIds(dataRuleIds);
			this.sysRolePermissionService.updateById(sysRolePermission);
		}
	} catch (Exception e) {
		log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
		return Result.error("保存失败");
	}
	return Result.ok("保存成功!");
}
 
Example #10
Source File: SysRoleController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("roleId") String roleId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			//return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysRolePermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #11
Source File: SysRolePermissionServiceImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
	List<String> add = getDiff(lastPermissionIds,permissionIds);
	if(add!=null && add.size()>0) {
		List<SysRolePermission> list = new ArrayList<SysRolePermission>();
		for (String p : add) {
			if(oConvertUtils.isNotEmpty(p)) {
				SysRolePermission rolepms = new SysRolePermission(roleId, p);
				list.add(rolepms);
			}
		}
		this.saveBatch(list);
	}
	
	List<String> delete = getDiff(permissionIds,lastPermissionIds);
	if(delete!=null && delete.size()>0) {
		for (String permissionId : delete) {
			this.remove(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId).eq(SysRolePermission::getPermissionId, permissionId));
		}
	}
}
 
Example #12
Source File: SysRoleController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 保存数据规则至角色菜单关联表
 */
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
	try {
		String permissionId = jsonObject.getString("permissionId");
		String roleId = jsonObject.getString("roleId");
		String dataRuleIds = jsonObject.getString("dataRuleIds");
		log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			return Result.error("请先保存角色菜单权限!");
		}else {
			sysRolePermission.setDataRuleIds(dataRuleIds);
			this.sysRolePermissionService.updateById(sysRolePermission);
		}
	} catch (Exception e) {
		log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
		return Result.error("保存失败");
	}
	return Result.ok("保存成功!");
}
 
Example #13
Source File: SysRolePermissionServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds) {
	LambdaQueryWrapper<SysRolePermission> query = new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId);
	this.remove(query);
	List<SysRolePermission> list = new ArrayList<SysRolePermission>();
       String[] arr = permissionIds.split(",");
	for (String p : arr) {
		if(oConvertUtils.isNotEmpty(p)) {
			SysRolePermission rolepms = new SysRolePermission(roleId, p);
			list.add(rolepms);
		}
	}
	this.saveBatch(list);
}
 
Example #14
Source File: SysPermissionController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 查询角色授权
 * 
 * @return
 */
@RequestMapping(value = "/queryRolePermission", method = RequestMethod.GET)
public Result<List<String>> queryRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
	Result<List<String>> result = new Result<>();
	try {
		List<SysRolePermission> list = sysRolePermissionService.list(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId));
		result.setResult(list.stream().map(SysRolePermission -> String.valueOf(SysRolePermission.getPermissionId())).collect(Collectors.toList()));
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example #15
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 查询角色授权
 * 
 * @return
 */
@RequestMapping(value = "/queryRolePermission", method = RequestMethod.GET)
public Result<List<String>> queryRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
	Result<List<String>> result = new Result<>();
	try {
		List<SysRolePermission> list = sysRolePermissionService.list(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId));
		result.setResult(list.stream().map(SysRolePermission -> String.valueOf(SysRolePermission.getPermissionId())).collect(Collectors.toList()));
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example #16
Source File: SysRolePermissionServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds) {
	LambdaQueryWrapper<SysRolePermission> query = new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId);
	this.remove(query);
	List<SysRolePermission> list = new ArrayList<SysRolePermission>();
       String[] arr = permissionIds.split(",");
	for (String p : arr) {
		if(oConvertUtils.isNotEmpty(p)) {
			SysRolePermission rolepms = new SysRolePermission(roleId, p);
			list.add(rolepms);
		}
	}
	this.saveBatch(list);
}
 
Example #17
Source File: SysRolePermissionServiceImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds) {
	LambdaQueryWrapper<SysRolePermission> query = new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId);
	this.remove(query);
	List<SysRolePermission> list = new ArrayList<SysRolePermission>();
       String[] arr = permissionIds.split(",");
	for (String p : arr) {
		if(oConvertUtils.isNotEmpty(p)) {
			SysRolePermission rolepms = new SysRolePermission(roleId, p);
			list.add(rolepms);
		}
	}
	this.saveBatch(list);
}
 
Example #18
Source File: SysPermissionController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 查询角色授权
 * 
 * @return
 */
@RequestMapping(value = "/queryRolePermission", method = RequestMethod.GET)
public Result<List<String>> queryRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
	Result<List<String>> result = new Result<>();
	try {
		List<SysRolePermission> list = sysRolePermissionService.list(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId));
		result.setResult(list.stream().map(SysRolePermission -> String.valueOf(SysRolePermission.getPermissionId())).collect(Collectors.toList()));
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example #19
Source File: SysPermissionController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 查询角色授权
 * 
 * @return
 */
@RequestMapping(value = "/queryRolePermission", method = RequestMethod.GET)
public Result<List<String>> queryRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
	Result<List<String>> result = new Result<>();
	try {
		List<SysRolePermission> list = sysRolePermissionService.list(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId));
		result.setResult(list.stream().map(SysRolePermission -> String.valueOf(SysRolePermission.getPermissionId())).collect(Collectors.toList()));
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example #20
Source File: SysRolePermissionServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void saveRolePermission(String roleId, String permissionIds) {
	LambdaQueryWrapper<SysRolePermission> query = new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId);
	this.remove(query);
	List<SysRolePermission> list = new ArrayList<SysRolePermission>();
       String[] arr = permissionIds.split(",");
	for (String p : arr) {
		if(oConvertUtils.isNotEmpty(p)) {
			SysRolePermission rolepms = new SysRolePermission(roleId, p);
			list.add(rolepms);
		}
	}
	this.saveBatch(list);
}