/* (非 Javadoc)
  * <p>Title: findAllFunctionList</p>
  * <p>Description:按节点查询所有程式 </p>
  * @param pid
  * @return
  */
 public List<TreeGridModel> findAllFunctionList(Integer pid) {
   String hql = "from Permission t where t.status='A' ";
   if (pid == null || "".equals(pid)) {
     hql += " and t.pid is null";
   } else {
     hql += " and t.pid=" + pid;
   }
   List<Permission> list = permissionPublicDao.find(hql);
   List<TreeGridModel> tempList = new ArrayList<TreeGridModel>();
   for (Permission function : list) {
     TreeGridModel treeGridModel = new TreeGridModel();
     try {
       BeanUtils.copyProperties(treeGridModel, function);
       if (pid == null || "".equals(pid)) {
         treeGridModel.setPid(null);
       }
       tempList.add(treeGridModel);
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     } catch (InvocationTargetException e) {
       e.printStackTrace();
     }
   }
   return tempList;
 }
 /* (非 Javadoc)
  * <p>Title: delFunction</p>
  * <p>Description: 删除程式</p>
  * @param id
  * @return
  */
 public boolean delFunction(Integer id) {
   String hql = " from Permission t where t.status='A' and t.pid=" + id;
   List<Permission> list = permissionPublicDao.find(hql);
   if (list.size() != 0) {
     return false;
   } else {
     Permission function = permissionPublicDao.get(Permission.class, id);
     function.setStatus(Constants.PERSISTENCE_DELETE_STATUS);
     function.setLastmod(new Date());
     function.setModifyer(Constants.getCurrendUser().getUserId());
     permissionPublicDao.deleteToUpdate(function);
     return true;
   }
 }
 public List<TreeModel> findAllFunctionList() {
   String hql = "from Permission t where t.status='A' and t.type='F' ";
   List<Permission> list = permissionPublicDao.find(hql);
   List<TreeModel> tempList = new ArrayList<TreeModel>();
   for (Permission function : list) {
     TreeModel treeModel = new TreeModel();
     treeModel.setId(function.getPermissionId().toString());
     treeModel.setPid(function.getPid() == null ? "" : function.getPid().toString());
     treeModel.setName(function.getName());
     treeModel.setIconCls(function.getIconCls());
     treeModel.setState(Constants.TREE_STATUS_OPEN);
     tempList.add(treeModel);
   }
   return tempList;
 }