Ejemplo n.º 1
0
 @Override
 @Transactional
 public Set<String> findUrls(String uid) {
   Set<String> urls = new HashSet<String>();
   String sql = "select rid from t_user_role where uid = ?";
   String sql2 = "select authid from t_role_auth where rid = ?";
   List rolelist = dao.findBySQl(sql, new String[] {uid});
   for (int i = 0; i < rolelist.size(); i++) {
     String rid = (String) rolelist.get(i); // 查找角色id
     List<Authority> authList = dao.findBySQl(sql2, new String[] {rid}); // 根据角色id查找权限id
     for (int j = 0; j < authList.size(); j++) {
       Authority authority = (Authority) dao.getObject(Authority.class, authList.get(i));
       urls.add(authority.getUrl());
     }
   }
   return urls;
 }
Ejemplo n.º 2
0
 @Override
 @Transactional
 public Set<String> findRoleName(String uid) {
   Set<String> roleNames = new HashSet<String>();
   String sql = "select rid from t_user_role where uid = ?";
   List rolelist = dao.findBySQl(sql, new String[] {uid});
   for (int i = 0; i < rolelist.size(); i++) {
     String rid = (String) rolelist.get(i); // 查找角色id
     Role role = (Role) dao.getObject(Role.class, rid);
     roleNames.add(role.getName());
   }
   return roleNames;
 }