⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menubean.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.sxit.wap.menu;
import java.sql.*;
import java.util.*;
import com.sxit.wap.common.*;
import com.sxit.wap.exception.*;
import com.sxit.wap.channel.*;
import com.sxit.wap.channelfee.*;

public class MenuBean extends MenuDao{
  public static Collection queryMenuByOrderParentId(int parentId) throws SysException {
    return queryBySql("SELECT * FROM " + tableName + " WHERE MENU_PARENT = " + parentId + " ORDER BY ORDER_ID");
  }
  public static Collection getMenuByMenuParent(int menuParent) throws SysException {
    String sql = "SELECT M.*, I.IMG_URL FROM WAP_MENU M, WAP_MENU_IMG I WHERE M.IMG_ID = I.ID AND MENU_PARENT = " + menuParent + " ORDER BY ORDER_ID";
    return queryBySql(sql);
  }
  public static int getMenuParent(int menuId) throws SysException {
    String sql = "SELECT MENU_PARENT FROM " + tableName + " WHERE MENU_ID = " + menuId;
    return getRowCountBySql(sql);
  }
  public static Collection getData1(int menuId,int i,String userMdn) throws SysException {
    String sql = "";

    if(i==0){
        sql = "SELECT M.*, I.IMG_URL FROM WAP_MENU M, WAP_MENU_IMG I,WAP_CHANNEL CH WHERE M.IMG_ID = I.ID AND M.MENU_PARENT = "
            + menuId + " AND CH.ID = M.MENU_CHANNEL AND CH.CHANNEL_TEST = 0";
      }else if(i==1){
        sql = "SELECT M.*, I.IMG_URL FROM WAP_MENU M, WAP_MENU_IMG I,WAP_CHANNEL CH WHERE M.IMG_ID = I.ID AND M.MENU_PARENT = "
            + menuId + " AND CH.ID = M.MENU_CHANNEL";
      }else{
        sql = "SELECT M.*, I.IMG_URL FROM WAP_MENU M, WAP_MENU_IMG I WHERE M.IMG_ID = I.ID AND M.MENU_PARENT = "
            + menuId;
      }
      System.out.println(sql);
      return getChannel(queryBySql(sql),userMdn);
    }

  public static Collection getTree() throws SysException {
    Collection value = new ArrayList();
    String sql = "SELECT M.*, I.IMG_URL FROM WAP_MENU_IMG I, ( " +
        " SELECT LEVEL, MENU_ID, MENU_PARENT, MENU_CHANNEL, MENU_NAME, IMG_ID " +
        " FROM WAP_MENU START WITH MENU_PARENT ='0' " +
        " CONNECT BY MENU_PARENT = PRIOR MENU_ID " +
        " ) M WHERE I.ID = M.IMG_ID";
    Collection coll = MenuBean.queryBySql(sql);
    Iterator it = coll.iterator();
    int index = 0;
    while ( it.hasNext() ) {
      Hashtable element = (Hashtable)it.next();
      String level = (String)element.get("level");
      String menuId = (String)element.get("menuId");
      String menuParent = (String)element.get("menuParent");
      String menuChannel = (String)element.get("menuChannel");
      String menuName = (String)element.get("menuName");
      int channelId = Integer.parseInt(menuChannel);
      String imgUrl = (String)element.get("imgUrl");
      TreeModel treeModel = new TreeModel();
      treeModel.setIndex(index++);
      treeModel.setId(Integer.parseInt(menuId));
      treeModel.setPid(Integer.parseInt(menuParent));
      treeModel.setName(menuName);
      treeModel.setLevel(Integer.parseInt(level));
      treeModel.setHasLeaf(channelId==0?1:0);
      treeModel.setIsOpen(1);
      treeModel.setIsAdmin(1);
      treeModel.setChannelId(Integer.parseInt(menuChannel));
      treeModel.setImgUrl(imgUrl);
      value.add(treeModel);
    }
    return value;
  }
  public static Collection getBranch() throws SysException {
    Collection value = new ArrayList();
    String sql = "SELECT LEVEL, MENU_ID, MENU_PARENT, MENU_CHANNEL, MENU_NAME FROM WAP_MENU START WITH MENU_PARENT ='0' CONNECT BY MENU_PARENT = PRIOR MENU_ID";
    Collection coll = MenuBean.queryBySql(sql);
    Iterator it = coll.iterator();
    int index = 0;
    while ( it.hasNext() ) {
      Hashtable element = (Hashtable)it.next();
      String level = (String)element.get("level");
      String menuId = (String)element.get("menuId");
      String menuParent = (String)element.get("menuParent");
      String menuChannel = (String)element.get("menuChannel");
      String menuName = (String)element.get("menuName");
      int channelId = Integer.parseInt(menuChannel);
      if (channelId != 0) continue;
      TreeModel treeModel = new TreeModel();
      treeModel.setIndex(index++);
      treeModel.setId(Integer.parseInt(menuId));
      treeModel.setPid(Integer.parseInt(menuParent));
      treeModel.setName(menuName);
      treeModel.setLevel(Integer.parseInt(level));
      treeModel.setHasLeaf(channelId==0?1:0);
      treeModel.setIsOpen(1);
      treeModel.setIsAdmin(1);
      treeModel.setChannelId(Integer.parseInt(menuChannel));
      value.add(treeModel);
    }
    return value;
  }
/*
  public static Collection getTree() throws SysException {
    Collection value = new ArrayList();
    String sql = "SELECT LEVEL, MENU_ID, MENU_PARENT, MENU_CHANNEL, MENU_NAME FROM WAP_MENU START WITH MENU_PARENT ='0' CONNECT BY MENU_PARENT = PRIOR MENU_ID";
    Collection coll = MenuBean.queryBySql(sql);
    Iterator it = coll.iterator();
    int index = 0;
    int lastLevel = 0;
    TreeModel treeModel = null;
    do {
      if (!it.hasNext()) break;
      Hashtable element = (Hashtable)it.next();
      String level = (String)element.get("level");
      String menuId = (String)element.get("menuId");
      String menuParent = (String)element.get("menuParent");
      String menuChannel = (String)element.get("menuChannel");
      String menuName = (String)element.get("menuName");
      if (treeModel != null) {
        if (Integer.parseInt(level) < treeModel.getLevel()) {
          treeModel.setHasLeaf(0);
        } else {
          treeModel.setHasLeaf(1);
        }
        value.add(treeModel);
      }
      treeModel = new TreeModel();
      treeModel.setIndex(index++);
      treeModel.setId(Integer.parseInt(menuId));
      treeModel.setPid(Integer.parseInt(menuParent));
      treeModel.setName(menuName);
      treeModel.setLevel(Integer.parseInt(level));
      treeModel.setHasLeaf(0);
      treeModel.setIsOpen(1);
      treeModel.setIsAdmin(1);
      treeModel.setChannelId(Integer.parseInt(menuChannel));
    } while ( it.hasNext() );
    if (treeModel != null) {
      value.add(tree
 Model);
    }
    return value;
  }
*/
  //取得所有菜单,并标示何种频道被批准(子目录)
  public static Collection getOkSysMenu()throws SysException{
    int arrayId=0;
    java.util.Collection subColl=new java.util.ArrayList();
    //BeanConnectionPool pool=BeanConnectionPool.GetInstance();
    Hashtable sh=new Hashtable();
    Connection conn=getConn();
    try {
      Statement stmt=conn.createStatement();
      String sql="select c.ID from wap_channel c where c.CHANNEL_STATUS=1";
      System.out.println(sql);
      ResultSet rs=stmt.executeQuery(sql);
      while (rs.next()) {
        sh.put(rs.getString("ID"),"1");
      }
      rs.close();
      sql="select level,MENU_ID,MENU_PARENT,MENU_NAME,MENU_CHANNEL from wap_menu "+
          "start with MENU_PARENT='0' "+
          "connect by MENU_PARENT=Prior MENU_ID";
      System.out.println(sql);
      rs=stmt.executeQuery(sql);
      NodeModel model=null;
      while (rs.next()) {
        int level=rs.getInt("level");
        if (model!=null) {
          if (model.getLevel()<level) {
            model.setHasLeaf("1");
          }
          subColl.add(model);
        }
        model=new NodeModel();
        model.setIndex(arrayId++);
        model.setLevel(level);
        model.setId(rs.getInt("MENU_ID"));
        model.setPid(rs.getInt("MENU_PARENT"));
        model.setName(rs.getString("MENU_NAME"));
        model.setHasLeaf("0");
        model.setIsopen("1");
        int channel=rs.getInt("MENU_CHANNEL");
        if (channel==0)
                {
          model.setIsok(-1);//该节点没有复选框
        }else
                {
          if (sh.get(String.valueOf(channel))==null)
                  {
            model.setIsok(0);//该节点有复选框,并且没有批准
          }else
                  {
            model.setIsok(1);//该节点有复选框,并且被批准
          }
         }
         model.setChannelId(channel);
      }//end of while
      if (model!=null) {
        subColl.add(model);
      }
      rs.close();
      stmt.close();
      //pool.freeConnection( conn ,0 );
    }catch(Exception se) {
      //pool.freeConnection( conn ,1 );
      se.printStackTrace();
      return null;//如果没有数据,返回空
    }finally {

      closeConn(conn);
    }

    return subColl.size()==0?null:subColl;//返回结果集
  }
  //取得某个节点*
  public static MenuModel getSysMenuByMenuId (int menuId) throws SysException {
    //BeanConnectionPool pool=BeanConnectionPool.GetInstance();
    Connection conn=getConn();
    MenuModel model=null;
    try {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -