Example #1
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;
 }
Example #2
0
 @Override
 @SuppressWarnings("unchecked")
 public User findUser(String username) {
   List<User> userList = dao.query("from User where username=?", new String[] {username});
   User user = userList.get(0);
   return user;
 }
Example #3
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;
 }