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

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

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

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

//3.获取角色对应的规则id
List<String> 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;
}
}
}

}
}
}

上一篇:Java Web应用中获取用户请求相关信息,如:IP地址、操作系统、浏览器等信息


下一篇:Asp.Net Design Pattern Studynotes -- Part1