<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Vector" %>

<%
    ConnectionFactory cf = new ConnectionFactory();
    Connection conn = null;
    Vector v_list = null;
    String json = "";
    StringBuffer sql = new StringBuffer();
    List list = new ArrayList();
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        sql.append("select id,p_id,dept_name as name,dept_order from t_book_dept  order by dept_order asc");
        v_list = cf.doQuery(conn, sql.toString(), null, list.toArray());
        if (v_list == null) {
            out.println("查询用户出错");
            return;
        }
        if(v_list != null && v_list.size() > 0){
            json = JSONArray.toJSON(v_list).toString();
        }
    } catch (Exception e) {
        out.println("查询用户信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }

    response.setContentType("application/json;charset=utf-8");
    response.getWriter().write(json.replace("p_id","pId"));
%>