/*
  * 根据用户来获取用户的权限
  * prur 传入一个用户编号
  */
 public List<Map> getUserPermission(PmRUserRole prur) throws Exception {
   // 检测缓存中是否有传入的用户,有则从缓存中取得用户信息,没有则从数据库中查询
   if (!(userMap != null && userMap.size() > 0 && userMap.get(prur.getRoleUserUid()) != null)) {
     StringBuffer sb = new StringBuffer();
     sb.append(
         "select * from pm_permission where PERMISSION_ID in (select role_permission_pid from pm_r_role_permissioin where role_permission_rid in (select role_user_rid from pm_r_user_role where role_user_uid=?) and role_permission_status=0)");
     Object[] obj = new Object[1];
     obj[0] = prur.getRoleUserUid();
     if (prur != null) {
       List<Map> listPermission = (List<Map>) this.executeQuery(sb.toString(), obj);
       if (listPermission != null && listPermission.size() > 0) {
         userMap.put(prur.getRoleUserUid(), listPermission);
         return listPermission;
       } else {
         return null;
       }
     }
   } else {
     return (List<Map>) userMap.get(prur.getRoleUserUid());
   }
   return null;
 }
 /*
  * 根据用户来获取用户的权限
  * prur 传入一个用户编号
  * pp传入一个父节点编号
  */
 public List<PmPermission> getUserPermission(PmRUserRole prur, PmPermission pp) throws Exception {
   StringBuffer sb = new StringBuffer();
   sb.append("from PmPermission where permissionId in(select rolePermissionPid ");
   sb.append("from PmRRolePermissioin where rolePermissionRid in ");
   sb.append(
       "(select roleUserRid from PmRUserRole where roleUserUid=?)) and permissionParentId=? ");
   Object[] obj = new Object[2];
   obj[0] = prur.getRoleUserUid();
   obj[1] = pp.getPermissionParentId();
   if (prur != null) {
     List<PmPermission> listPermission = (List<PmPermission>) this.query(sb.toString(), obj);
     if (listPermission != null && listPermission.size() > 0) {
       return listPermission;
     }
   }
   return null;
 }
 /*
  * 查询用户的单个角色
  */
 public boolean boolUserPermission(PmRUserRole prur, PmPermission pp) throws Exception {
   StringBuffer sb = new StringBuffer();
   sb.append(
       "select count(*) as count from pm_r_user_role prur LEFT JOIN pm_r_role_permissioin prrp on prur.ROLE_USER_RID=prrp.ROLE_PERMISSION_RID");
   sb.append(" LEFT JOIN pm_permission pp on pp.PERMISSION_ID=prrp.ROLE_PERMISSION_PID");
   sb.append(" where prur.ROLE_USER_UID=? and pp.PERMISSION_URI=?");
   Object[] obj = new Object[2];
   obj[0] = prur.getRoleUserUid();
   obj[1] = pp.getPermissionUri();
   // 判断传入参数是否为空,查询用户和uri是否存在
   if (prur != null && pp != null) {
     List<Map> listCount = (List<Map>) this.executeQuery(sb.toString(), obj);
     // 返回的记录数是否大于0
     if (listCount != null && listCount.size() > 0) {
       if (Integer.parseInt(listCount.get(0).get("count").toString()) > 0) {
         return true;
       }
     }
   }
   return false;
 }