設計組織樹 通過java拼接xml組織樹 實現介面組織樹 通過資料庫配置動態決定菜單樹顯示與否、排列優先__資料庫

來源:互聯網
上載者:User

資料庫組織樹結構設計

 

java實現代碼,拼接xml組織樹

public String loadAreaTree() {StringBuffer areaTreeStr = new StringBuffer();areaTreeStr.append("<>");//查詢出第一級地區 所有的國家List<Area> countryList = hibernateTemplate.getSessionFactory().openSession().createQuery("from Area p where p.parentAreaNo = '#' and p.isVisible ='true' order by p.leafNo").list();if(countryList != null && countryList.size() > 0){for (Area countryArea : countryList) {areaTreeStr.append("<country areaName=\""+countryArea.getAreaName()+"\" urls=\""+countryArea.getUrls()+"\">");//查詢出第二級地區 所有的省份(該國家下)List<Area> provinceAreaList = hibernateTemplate.getSessionFactory().openSession().createQuery("from Area p where p.parentAreaNo =:countryAreaNo and p.isVisible ='true' order by p.leafNo").setString("countryAreaNo", countryArea.getAreaNO().toString()).list();if(provinceAreaList != null && provinceAreaList.size() > 0){for (Area provinceArea : provinceAreaList) {areaTreeStr.append("<province areaName=\""+provinceArea.getAreaName()+"\" urls=\""+provinceArea.getUrls()+"\">");//查詢出第三級地區 所有的城市(該省份下)List<Area> cityAreaList = hibernateTemplate.getSessionFactory().openSession().createQuery("from Area p where p.parentAreaNo =:provinceAreaNo and p.isVisible ='true' order by p.leafNo").setString("provinceAreaNo", provinceArea.getAreaNO().toString()).list();if(cityAreaList != null && cityAreaList.size() > 0){for (Area cityArea : cityAreaList) {areaTreeStr.append("<city areaName=\""+cityArea.getAreaName()+"\" urls=\""+cityArea.getUrls()+"\"></city>");}}areaTreeStr.append("</province>");}}areaTreeStr.append("</country>");}return areaTreeStr.append("</>").toString();}else{return "";}}


介面展現

 

點擊菜單 會連結到指定 urls

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.