/**
   * 根据ID返回详细信息
   *
   * @param
   * @return
   * @throws
   */
  public List treeList(IBaseDTO dto, PageInfo pi, String id) {

    List list = new ArrayList();

    LeafRightSearch lrs = new LeafRightSearch();

    Object[] result = (Object[]) dao.findEntity(lrs.treeList(dto, pi, id));
    num = dao.findEntitySize(lrs.treeList(dto, pi, id));
    for (int i = 0, size = result.length; i < size; i++) {
      SysLeafRight slr = (SysLeafRight) result[i];
      DynaBeanDTO dbd = new DynaBeanDTO();

      dbd.set("id", slr.getId());
      dbd.set("treeId", slr.getId());
      dbd.set("treeType", slr.getType());
      dbd.set("label", slr.getLabel());
      dbd.set("nickName", slr.getNickName());
      String remark = slr.getRemark() == null ? "" : slr.getRemark();
      if (remark.length() > 15) {
        remark = remark.substring(0, 15);
      }
      dbd.set("remark", remark);
      dbd.set("icon", slr.getIcon());
      list.add(dbd);
    }
    return list;
  }
  /**
   * 树节点的增加
   *
   * @param IBaseDTO dto 是BaseTree 和 ViewTreeDict的信息
   * @return
   * @throws
   */
  public void addDict(IBaseDTO dto, String treeId) {

    SysLeafRight slr = new SysLeafRight();

    BaseTree bt = (BaseTree) dao.loadEntity(BaseTree.class, treeId);

    slr.setId(ks.getNext("sys_leaf_right"));
    slr.setBaseTree(bt);
    slr.setType(dto.get("treeType").toString());
    slr.setLabel(dto.get("label").toString());
    slr.setNickName(dto.get("nickName").toString());
    slr.setRemark(dto.get("remark").toString());
    slr.setIcon(dto.get("icon").toString());
    slr.setDeleteMark(dto.get("deleteMark").toString());
    slr.setIcon((String) dto.get("icon"));
    dao.saveEntity(slr);
  }
  /**
   * 根据ID返回详细信息
   *
   * @param
   * @return
   * @throws
   */
  public IBaseDTO treeInfo(String id) {

    SysLeafRight slr = (SysLeafRight) dao.loadEntity(SysLeafRight.class, id);
    IBaseDTO dto = new DynaBeanDTO();

    dto.set("id", slr.getId());
    dto.set("treeId", slr.getId());
    dto.set("treeType", slr.getType());
    dto.set("label", slr.getLabel());
    dto.set("nickName", slr.getNickName());
    dto.set("remark", slr.getRemark());

    return dto;
  }
  /**
   * 树节点的修改
   *
   * @param IBaseDTO dto 是BaseTree 和 ViewTreeDict的信息
   * @return
   * @throws
   */
  public boolean updateDict(IBaseDTO dto) {
    SysLeafRight slr = (SysLeafRight) dao.loadEntity(SysLeafRight.class, dto.get("id").toString());

    slr.setLabel(dto.get("label").toString());
    slr.setNickName(dto.get("nickName").toString());
    slr.setRemark(dto.get("remark").toString());
    slr.setDeleteMark(dto.get("deleteMark").toString());
    slr.setIcon(dto.get("icon").toString());
    slr.setType(dto.get("treeType").toString());

    dao.updateEntity(slr);

    return true;
  }
 /**
  * 得到叶子节点权限列表
  *
  * @param nodeId
  * @return List<SysLeafRight>
  */
 public List<DynaBeanDTO> getLeafRightByNodeId(String nodeId) {
   List<DynaBeanDTO> rights = new ArrayList<DynaBeanDTO>();
   if (nodeId != null) {
     String hql = "from SysLeafRight where a.baseTree.id = '" + nodeId + "' order by a.nickName";
     MyQuery mq = new MyQueryImpl();
     mq.setHql(hql);
     Object[] o = dao.findEntity(searchHelp.searchLeafRightByNodeId(nodeId));
     DynaBeanDTO dto = null;
     for (int i = 0; i < o.length; i++) {
       dto = new DynaBeanDTO();
       SysLeafRight right = (SysLeafRight) o[i];
       dto.set("id", right.getId());
       dto.set("treeId", right.getBaseTree().getId());
       dto.set("treeName", right.getBaseTree().getLabel());
       dto.set("type", right.getType());
       dto.set("nickName", right.getNickName());
       dto.set("deleteMark", right.getDeleteMark());
       dto.set("remark", right.getRemark());
       rights.add(dto);
     }
   }
   return rights;
 }