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

The following examples show how to use org.jeecg.modules.system.entity.SysPermissionDataRule. 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: SysPermissionDataRuleImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
@Transactional
public void deletePermissionDataRule(String dataRuleId) {
	SysPermissionDataRule dataRule = this.baseMapper.selectById(dataRuleId);
	if(dataRule!=null) {
		this.removeById(dataRuleId);
		Integer count =  this.baseMapper.selectCount(new LambdaQueryWrapper<SysPermissionDataRule>().eq(SysPermissionDataRule::getPermissionId, dataRule.getPermissionId()));
		//注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效
		if(count==null || count==0) {
			SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId());
			if(permission!=null && permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_1)) {
				permission.setRuleFlag(CommonConstant.RULE_FLAG_0);
				sysPermissionMapper.updateById(permission);
			}
		}
	}
	
}
 
Example #2
Source File: SysDepartPermissionController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
* 部门管理授权查询数据规则数据
*/
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
	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<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
			 .eq(SysDepartPermission::getPermissionId, permissionId)
			 .eq(SysDepartPermission::getDepartId,departId);
		SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
		if(sysDepartPermission==null) {
		 //return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysDepartPermission.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 #3
Source File: SysDepartPermissionController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
* 部门管理授权查询数据规则数据
*/
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
	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<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
			 .eq(SysDepartPermission::getPermissionId, permissionId)
			 .eq(SysDepartPermission::getDepartId,departId);
		SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
		if(sysDepartPermission==null) {
		 //return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysDepartPermission.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 #4
Source File: SysDepartRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{departId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId,@PathVariable("roleId") String roleId) {
//查询已授权的部门规则
	List<SysPermissionDataRule> list = sysDepartPermissionService.getPermRuleListByDeptIdAndPermId(departId,permissionId);
 if(list==null || list.size()==0) {
	 return Result.error("未找到权限配置信息");
 }else {
	 Map<String,Object> map = new HashMap<>();
	 map.put("datarule", list);
	 LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
			 .eq(SysDepartRolePermission::getPermissionId, permissionId)
			 .eq(SysDepartRolePermission::getRoleId,roleId);
	 SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.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: SysDepartPermissionController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
* 部门管理授权查询数据规则数据
*/
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
	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<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
			 .eq(SysDepartPermission::getPermissionId, permissionId)
			 .eq(SysDepartPermission::getDepartId,departId);
		SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
		if(sysDepartPermission==null) {
		 //return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysDepartPermission.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 #6
Source File: SysPermissionDataRuleImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
public List<SysPermissionDataRule> queryPermissionDataRules(String username,String permissionId) {
	List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId);
	//update-begin--Author:scott  Date:20191119  for:数据权限失效问题处理--------------------
	if(idsList==null || idsList.size()==0) {
		return null;
	}
	//update-end--Author:scott  Date:20191119  for:数据权限失效问题处理--------------------
	Set<String> set = new HashSet<String>();
	for (String ids : idsList) {
		if(oConvertUtils.isEmpty(ids)) {
			continue;
		}
		String[] arr = ids.split(",");
		for (String id : arr) {
			if(oConvertUtils.isNotEmpty(id) && !set.contains(id)) {
				set.add(id);
			}
		}
	}
	if(set.size()==0) {
		return null;
	}
	return this.baseMapper.selectList(new QueryWrapper<SysPermissionDataRule>().in("id", set).eq("status",CommonConstant.STATUS_1));
}
 
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: 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 #9
Source File: SysPermissionDataRuleImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public List<SysPermissionDataRule> queryPermissionDataRules(String username,String permissionId) {
	List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId);
	//update-begin--Author:scott  Date:20191119  for:数据权限失效问题处理--------------------
	if(idsList==null || idsList.size()==0) {
		return null;
	}
	//update-end--Author:scott  Date:20191119  for:数据权限失效问题处理--------------------
	Set<String> set = new HashSet<String>();
	for (String ids : idsList) {
		if(oConvertUtils.isEmpty(ids)) {
			continue;
		}
		String[] arr = ids.split(",");
		for (String id : arr) {
			if(oConvertUtils.isNotEmpty(id) && !set.contains(id)) {
				set.add(id);
			}
		}
	}
	if(set.size()==0) {
		return null;
	}
	return this.baseMapper.selectList(new QueryWrapper<SysPermissionDataRule>().in("id", set).eq("status",CommonConstant.STATUS_1));
}
 
Example #10
Source File: SysPermissionDataRuleImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
public List<SysPermissionDataRule> queryPermissionDataRules(String username,String permissionId) {
	List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId);
	if(idsList==null || idsList.size()==0 || idsList.get(0)==null ) {
		return null;
	}
	Set<String> set = new HashSet<String>();
	for (String ids : idsList) {
		if(ids==null) {
			continue;
		}
		String[] arr = ids.split(",");
		for (String id : arr) {
			if(oConvertUtils.isNotEmpty(id)) {
				set.add(id);
			}
		}
	}
	if(set.size()==0) {
		return null;
	}
	return this.baseMapper.selectList(new QueryWrapper<SysPermissionDataRule>().in("id", set).eq("status",CommonConstant.STATUS_1));
}
 
Example #11
Source File: SysPermissionDataRuleImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional
public void deletePermissionDataRule(String dataRuleId) {
	SysPermissionDataRule dataRule = this.baseMapper.selectById(dataRuleId);
	if(dataRule!=null) {
		this.removeById(dataRuleId);
		Integer count =  this.baseMapper.selectCount(new LambdaQueryWrapper<SysPermissionDataRule>().eq(SysPermissionDataRule::getPermissionId, dataRule.getPermissionId()));
		//注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效
		if(count==null || count==0) {
			SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId());
			if(permission!=null && permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_1)) {
				permission.setRuleFlag(CommonConstant.RULE_FLAG_0);
				sysPermissionMapper.updateById(permission);
			}
		}
	}
	
}
 
Example #12
Source File: QueryGenerator.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 
 * @return
 */
public static Map<String, SysPermissionDataRule> getRuleMap() {
	Map<String, SysPermissionDataRule> ruleMap = new HashMap<String, SysPermissionDataRule>();
	List<SysPermissionDataRule> list =JeecgDataAutorUtils.loadDataSearchConditon();
	if(list != null&&list.size()>0){
		if(list.get(0)==null){
			return ruleMap;
		}
		for (SysPermissionDataRule rule : list) {
			String column = rule.getRuleColumn();
			if(QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) {
				column = SQL_RULES_COLUMN+rule.getId();
			}
			ruleMap.put(column, rule);
		}
	}
	return ruleMap;
}
 
Example #13
Source File: QueryGenerator.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
private static void addRuleToQueryWrapper(SysPermissionDataRule dataRule,String name, Class propertyType, QueryWrapper<?> queryWrapper) {
	QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions());
	if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) {
		String[] values = dataRule.getRuleValue().split(",");
		Object[] objs = new Object[values.length];
		for (int i = 0; i < values.length; i++) {
			objs[i] = NumberUtils.parseNumber(values[i], propertyType);
		}
		addEasyQuery(queryWrapper, name, rule, objs);
	}else {
		if (propertyType.equals(String.class)) {
			addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue()));
		} else {
			addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType));
		}
	}
}
 
Example #14
Source File: QueryGenerator.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
  * 根据权限相关配置 组装mp需要的权限
 * @param searchObj
 * @param parameterMap
 * @return
 */
public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) {
	//权限查询
	Map<String,SysPermissionDataRule> ruleMap = getRuleMap();
	PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz);
	for (String c : ruleMap.keySet()) {
		if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){
			queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue())));
		}
	}
	String name;
	for (int i = 0; i < origDescriptors.length; i++) {
		name = origDescriptors[i].getName();
		if (judgedIsUselessField(name)) {
			continue;
		}
		if(ruleMap.containsKey(name)) {
			addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper);
		}
	}
}
 
Example #15
Source File: SysPermissionDataRuleImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional
public void deletePermissionDataRule(String dataRuleId) {
	SysPermissionDataRule dataRule = this.baseMapper.selectById(dataRuleId);
	if(dataRule!=null) {
		this.removeById(dataRuleId);
		Integer count =  this.baseMapper.selectCount(new LambdaQueryWrapper<SysPermissionDataRule>().eq(SysPermissionDataRule::getPermissionId, dataRule.getPermissionId()));
		//注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效
		if(count==null || count==0) {
			SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId());
			if(permission!=null && permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_1)) {
				permission.setRuleFlag(CommonConstant.RULE_FLAG_0);
				sysPermissionMapper.updateById(permission);
			}
		}
	}
	
}
 
Example #16
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 #17
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 #18
Source File: SysPermissionDataRuleImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional
public void deletePermissionDataRule(String dataRuleId) {
	SysPermissionDataRule dataRule = this.baseMapper.selectById(dataRuleId);
	if(dataRule!=null) {
		this.removeById(dataRuleId);
		Integer count =  this.baseMapper.selectCount(new LambdaQueryWrapper<SysPermissionDataRule>().eq(SysPermissionDataRule::getPermissionId, dataRule.getPermissionId()));
		//注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效
		if(count==null || count==0) {
			SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId());
			if(permission!=null && permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_1)) {
				permission.setRuleFlag(CommonConstant.RULE_FLAG_0);
				sysPermissionMapper.updateById(permission);
			}
		}
	}
	
}
 
Example #19
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 删除菜单权限数据
 * 
 * @param sysPermissionDataRule
 * @return
 */
@RequestMapping(value = "/deletePermissionRule", method = RequestMethod.DELETE)
public Result<SysPermissionDataRule> deletePermissionRule(@RequestParam(name = "id", required = true) String id) {
	Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
	try {
		sysPermissionDataRuleService.deletePermissionDataRule(id);
		result.success("删除成功!");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #20
Source File: SysPermissionController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 根据菜单id来获取其对应的权限数据
 * 
 * @param sysPermissionDataRule
 * @return
 */
@RequestMapping(value = "/getPermRuleListByPermId", method = RequestMethod.GET)
public Result<List<SysPermissionDataRule>> getPermRuleListByPermId(SysPermissionDataRule sysPermissionDataRule) {
	List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.getPermRuleListByPermId(sysPermissionDataRule.getPermissionId());
	Result<List<SysPermissionDataRule>> result = new Result<>();
	result.setSuccess(true);
	result.setResult(permRuleList);
	return result;
}
 
Example #21
Source File: SysPermissionServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 根据permissionId删除其关联的SysPermissionDataRule表中的数据
 */
@Override
public void deletePermRuleByPermId(String id) {
	LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<>();
	query.eq(SysPermissionDataRule::getPermissionId, id);
	int countValue = this.permissionDataRuleService.count(query);
	if(countValue > 0) {
		this.permissionDataRuleService.remove(query);	
	}
}
 
Example #22
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 添加菜单权限数据
 * 
 * @param sysPermissionDataRule
 * @return
 */
@RequestMapping(value = "/addPermissionRule", method = RequestMethod.POST)
public Result<SysPermissionDataRule> addPermissionRule(@RequestBody SysPermissionDataRule sysPermissionDataRule) {
	Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
	try {
		sysPermissionDataRule.setCreateTime(new Date());
		sysPermissionDataRuleService.savePermissionDataRule(sysPermissionDataRule);
		result.success("添加成功!");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #23
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 根据菜单id来获取其对应的权限数据
 * 
 * @param sysPermissionDataRule
 * @return
 */
@RequestMapping(value = "/getPermRuleListByPermId", method = RequestMethod.GET)
public Result<List<SysPermissionDataRule>> getPermRuleListByPermId(SysPermissionDataRule sysPermissionDataRule) {
	List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.getPermRuleListByPermId(sysPermissionDataRule.getPermissionId());
	Result<List<SysPermissionDataRule>> result = new Result<>();
	result.setSuccess(true);
	result.setResult(permRuleList);
	return result;
}
 
Example #24
Source File: SysPermissionDataRuleImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
@Override
@Transactional
public void savePermissionDataRule(SysPermissionDataRule sysPermissionDataRule) {
	this.save(sysPermissionDataRule);
	SysPermission permission = sysPermissionMapper.selectById(sysPermissionDataRule.getPermissionId());
	if(permission!=null && (permission.getRuleFlag()==null || permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_0))) {
		permission.setRuleFlag(CommonConstant.RULE_FLAG_1);
		sysPermissionMapper.updateById(permission);
	}
}
 
Example #25
Source File: SysPermissionDataRuleImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
public void savePermissionDataRule(SysPermissionDataRule sysPermissionDataRule) {
	this.save(sysPermissionDataRule);
	SysPermission permission = sysPermissionMapper.selectById(sysPermissionDataRule.getPermissionId());
	if(permission!=null && (permission.getRuleFlag()==null || permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_0))) {
		permission.setRuleFlag(CommonConstant.RULE_FLAG_1);
		sysPermissionMapper.updateById(permission);
	}
}
 
Example #26
Source File: SysPermissionServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 根据permissionId删除其关联的SysPermissionDataRule表中的数据
 */
@Override
public void deletePermRuleByPermId(String id) {
	LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<>();
	query.eq(SysPermissionDataRule::getPermissionId, id);
	int countValue = this.permissionDataRuleService.count(query);
	if(countValue > 0) {
		this.permissionDataRuleService.remove(query);	
	}
}
 
Example #27
Source File: SysPermissionDataRuleImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 根据菜单id查询其对应的权限数据
 */
@Override
public List<SysPermissionDataRule> getPermRuleListByPermId(String permissionId) {
	LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
	query.eq(SysPermissionDataRule::getPermissionId, permissionId);
	query.orderByDesc(SysPermissionDataRule::getCreateTime);
	List<SysPermissionDataRule> permRuleList = this.list(query);
	return permRuleList;
}
 
Example #28
Source File: SysPermissionController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 查询菜单权限数据
 * 
 * @param sysPermissionDataRule
 * @return
 */
@RequestMapping(value = "/queryPermissionRule", method = RequestMethod.GET)
public Result<List<SysPermissionDataRule>> queryPermissionRule(SysPermissionDataRule sysPermissionDataRule) {
	Result<List<SysPermissionDataRule>> result = new Result<>();
	try {
		List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.queryPermissionRule(sysPermissionDataRule);
		result.setResult(permRuleList);
		result.success("查询成功!");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		result.error500("操作失败");
	}
	return result;
}
 
Example #29
Source File: SysDepartPermissionServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
public List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId, String permissionId) {
    SysDepartPermission departPermission = this.getOne(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
    if(departPermission != null){
        LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
        query.in(SysPermissionDataRule::getId, Arrays.asList(departPermission.getDataRuleIds().split(",")));
        query.orderByDesc(SysPermissionDataRule::getCreateTime);
        List<SysPermissionDataRule> permRuleList = this.ruleMapper.selectList(query);
        return permRuleList;
    }else{
        return null;
    }
}
 
Example #30
Source File: SysPermissionDataRuleImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 根据菜单id查询其对应的权限数据
 */
@Override
public List<SysPermissionDataRule> getPermRuleListByPermId(String permissionId) {
	LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
	query.eq(SysPermissionDataRule::getPermissionId, permissionId);
	query.orderByDesc(SysPermissionDataRule::getCreateTime);
	List<SysPermissionDataRule> permRuleList = this.list(query);
	return permRuleList;
}