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

📄 statdao.java

📁 EasyJForum 是一个基于 Java 技术的免费社区论坛软件系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        
                        visits[0] = rs.getInt("tc");
                        visits[1] = rs.getInt("rc");
                        visits[2] = rs.getInt("uc");
                        visits[3] = rs.getInt("vc");
                    }
                }
                result[1] = visitList;
            }
        }
        finally
        {
            dbManager.closeResultSet(rs);
            dbManager.closePStatement(pstmtQuery);
            dbManager.closeConnection(conn);
        }
        // Get result page code
        if (totalCount > 0)
        {
            int pageCount = (totalCount - 1) / pageRows + 1;
            if (pageCount <= 1) return result;
            result[0] = PageUtils.getPageHTMLStr(totalCount, pageNo, pageRows, 0);
        }        
        return result;
    }

    /**
     * 查询论坛版块排行信息
     * @param none
     * @return 统计信息
     * @throws SQLException
     * @since 1.0
     */
    @SuppressWarnings("unchecked")
    public Object[] getTopBoardsInfo() throws SQLException
    {
        Object[] result = new Object[3];
        
        CacheManager cache = CacheManager.getInstance();
        ArrayList<SectionVO> sections = cache.getSections();
        ArrayList<BoardVO> topTopicsBoards = new ArrayList<BoardVO>();
        ArrayList<BoardVO> topRepliesBoards = new ArrayList<BoardVO>();
        SectionVO aSection = null;
        BoardVO aBoard = null;
        
        for (int i=0; i<sections.size(); i++)
        {
            aSection = sections.get(i);
            for (int j=0; j<aSection.boardList.size(); j++)
            {
                aBoard = aSection.boardList.get(j);

                int k = 0;
                while(k < topTopicsBoards.size())
                {
                    if (aBoard.topics < topTopicsBoards.get(k).topics)
                        k++;
                    else
                        break;
                }
                topTopicsBoards.add(k, aBoard);
                
                k = 0;
                while(k < topRepliesBoards.size())
                {
                    if (aBoard.replies < topRepliesBoards.get(k).replies)
                        k++;
                    else
                        break;
                }
                topRepliesBoards.add(k, aBoard);
            }
        }

        result[0] = topTopicsBoards;
        result[1] = topRepliesBoards;
        
        Connection conn = null;
        PreparedStatement pstmtQuery = null;
        ResultSet rs = null;
        try
        {
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, -30);
            
            conn = dbManager.getConnection();
            pstmtQuery = conn.prepareStatement(adapter.VisitStat_30DaysTopBoards);
            pstmtQuery.setDate(1, new Date(cal.getTimeInMillis()));
            rs = pstmtQuery.executeQuery();
            
            ArrayList<HashMap> boardList = new ArrayList<HashMap>();
            HashMap boardMap = null;
                
            while(rs.next())
            {
                aBoard = cache.getBoard(rs.getString("boardID"));
                if (aBoard != null)
                {
                    boardMap = new HashMap();
                    boardMap.put("sectionID", aBoard.sectionID);
                    boardMap.put("boardID", aBoard.boardID);
                    boardMap.put("boardName", aBoard.boardName);
                    boardMap.put("ct", rs.getString("ct"));
                    boardList.add(boardMap);
                }
            }
            result[2] = boardList;
        }
        finally
        {
            dbManager.closeResultSet(rs);
            dbManager.closePStatement(pstmtQuery);
            dbManager.closeConnection(conn);
        }
        return result;
    }

    /**
     * 查询论坛主题排行信息
     * @param none
     * @return 统计信息
     * @throws SQLException
     * @since 1.0
     */
    public Object[] getTopTopicsInfo() throws SQLException
    {
        Object[] result = new Object[2];
        Connection conn = null;
        try
        {
            int pageNo = 1;
            int pageRows = 15;
            
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, -30);
            SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
            String statDate = dateFormatter.format(cal.getTime());
            
            ArrayList<Object> paramValues = new ArrayList<Object>();
            paramValues.add(Date.valueOf(statDate));
            
            conn = dbManager.getConnection();

            String sql = adapter.getPageQuerySql(
                    new StringBuilder(adapter.VisitStat_TopVisitsTopics),
                    pageNo, pageRows, 15);
            
            result[0] = this.execSelectSql(sql, paramValues, conn);

            sql = adapter.getPageQuerySql(
                    new StringBuilder(adapter.VisitStat_TopRepliesTopics),
                    pageNo, pageRows, 15);
            result[1] = this.execSelectSql(sql, paramValues, conn);
        }
        finally
        {
            dbManager.closeConnection(conn);
        }
        return result;
    }

    /**
     * 查询论坛会员排行信息
     * @param none
     * @return 统计信息
     * @throws SQLException
     * @since 1.0
     */
    public Object[] getTopUsersInfo() throws SQLException
    {
        Object[] result = new Object[2];
        Connection conn = null;
        try
        {
            int pageNo = 1;
            int pageRows = 15;
            
            conn = dbManager.getConnection();

            String sql = adapter.getPageQuerySql(
                            new StringBuilder(adapter.VisitStat_TopCreditsUsers),
                            pageNo, pageRows, 15);
            result[0] = this.execSelectSql(sql, null, conn);

            sql = adapter.getPageQuerySql(
                            new StringBuilder(adapter.VisitStat_TopPostsUsers),
                            pageNo, pageRows, 15);
            result[1] = this.execSelectSql(sql, null, conn);
        }
        finally
        {
            dbManager.closeConnection(conn);
        }
        return result;
    }

    /**
     * 查询论坛管理员和版主信息
     * @param none
     * @return 统计信息
     * @throws SQLException
     * @since 1.0
     */
    public ArrayList<HashMap> getAdminUsersInfo() throws SQLException
    {
        String moderators = CacheManager.getInstance().getModerators();
        String[] userIDs = moderators.split(",");
        
        StringBuilder sbuf = new StringBuilder();
        sbuf.append(" (");
        for (int i=0; i<userIDs.length; i++)
        {
            if (userIDs[i].length() == 0) continue;
            if (sbuf.length() > 2) sbuf.append(",");
            sbuf.append("'").append(userIDs[i]).append("'");
        }
        if (sbuf.length() == 2)
            sbuf.append("'").append(AppContext.getInstance().getAdminUser()).append("'");
        sbuf.append(")");
            
        String sql = adapter.VisitStat_AdminUsers + sbuf.toString();
        return this.execSelectSql(sql, null);
    }
    
}

⌨️ 快捷键说明

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