<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.db.DBUtil" %>
<%@ page import="com.censoft.db.Logger" %>
<%
    Pub pub = new Pub();
    String s_id = pub.trimNull((String) session.getAttribute("session_login_id"));
    String menu_id = pub.trimNull(request.getParameter("menu_id"));
    if ("".equals(s_id) || "".equals(menu_id)) {
        return;
    }
    ConnectionFactory cf = new ConnectionFactory();
    Connection conn = null;
    Vector v_list = null;
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        StringBuffer sb = new StringBuffer();
        sb.append(" select distinct menu.* from t_book_role_menu_rel rel  ");
        sb.append(" join t_book_role role on role.id=rel.role_id ");
        sb.append(" join t_book_user_role_rel ur on ur.role_id=role.id ");
        sb.append(" join  zb_bgs_user ad on ad.id=ur.login_id ");
        sb.append(" join t_book_menu menu on menu.id=rel.menu_id ");
        sb.append(" where ad.id=? and  menu.p_id =? and (menu.sys_id='3' or menu.sys_id is null) order by menu.menu_order asc");
        v_list = cf.doQuery(conn, sb.toString(), null, new Object[]{s_id, menu_id});
        if(false){
            sb = new StringBuffer("select * from t_book_menu menu where menu.p_id=?    order by  menu_order asc");
            v_list = cf.doQuery(conn, sb.toString(), null, new Object[]{menu_id});
        }
        if (v_list == null) {
            out.println("查询角色出错");
            return;
        }
    } catch (Exception e) {
        out.println("查询角色信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>
<ul>
    <%
        if (v_list != null && v_list.size() > 0) {
            for (int i = 0; i < v_list.size(); i++) {
                Hashtable ht = (Hashtable) v_list.get(i);
                String menu_name = pub.trimNull((String) ht.get("menu_name"));
                String menu_url = pub.trimNull((String) ht.get("menu_url"));
                String id = pub.trimNull((String) ht.get("id"));
                if (!"#".equals(menu_url)) {
                    if (menu_url.indexOf("?") > 0) {
                        menu_url += "&menu_id=" + id;
                    } else {
                        menu_url += "?menu_id=" + id;
                    }
                }
                String menu_pic = pub.trimNull((String) ht.get("menu_pic"))+";";
                if ("".equals(menu_pic)) menu_pic = "&#xe620;";
    %>
    <li><a data-href="<%=menu_url%>" data-title="<%=menu_name%>" href="javascript:void(0)"><i class="Hui-iconfont"><%=menu_pic%></i>&nbsp;<%=menu_name%>
    </a></li>
    <%
            }
        }
    %>
</ul>