jeecg中获取用户拥有的角色的数据权限

String roles1="";
String sql="";

//1.获取用户
TSUser user = ResourceUtil.getSessionUser();

//2.获取用户的角色
List rUsers1 = systemService.findByProperty(TSRoleUser.class, "TSUser.id", user.getId());
for (TSRoleUser ru : rUsers1) {

//3.获取角色对应的规则id
List datarules =jdbcTemplate.queryForList("select datarule from t_s_role_function where roleid=(select roleid from t_s_role_user where id=?) ",String.class,ru.getId()) ;
for (String string : datarules) {
if(StringUtil.isNotEmpty(string)){
for (String datarule : string.split(",")) {
if(StringUtil.isNotEmpty(datarule)){

//4.获取规则名称的sql语句
String rulevalue=jdbcTemplate.queryForObject("select rule_value from t_s_data_rule where id =? ",String.class,datarule) ;
if(rulevalue.contains("goods_Place")){

//5.做逻辑判断

sql= sql+" and " +rulevalue;
}
}
}

}
}
}

你可能感兴趣的:(jeecg中获取用户拥有的角色的数据权限)