?? dlogdao.java
字號:
/*
* DlogDAO.java
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Author: Winter Lau (javayou@gmail.com)
* http://dlog4j.sourceforge.net
*/
package com.liusoft.dlog4j.dao;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import com.liusoft.dlog4j.base.DlogStatInfo;
/**
* DLOG4J平臺獨立的數據庫訪問方法
* @author Winter Lau
*/
public class DlogDAO extends DAO {
/**
* 獲取制定網站最熱門的標簽,如果網站沒指定(site=-1)則查詢所有網站
* @param site
* @param count
* @return
*/
public static List listHotTags(int site, int count){
Session ssn = getSession();
StringBuffer sql = new StringBuffer("SELECT tag_name,COUNT(*) FROM dlog_tag");
if(site>0)
sql.append(" WHERE site_id=?");
sql.append(" GROUP BY tag_name ORDER BY 2 DESC");
SQLQuery query = ssn.createSQLQuery(sql.toString());
if(site>0)
query.setInteger(0, site);
query.setMaxResults(count);
List tags = new ArrayList();
List results = query.list();
for(int i=0;results!=null && i<results.size();i++){
tags.add(((Object[])results.get(i))[0]);
}
return tags;
}
/**
* 返回指定網站的統計信息,如果site值小于0則取所有網站
* @param site
* @return
*/
public static DlogStatInfo getDlogStatInfo(int site){
DlogStatInfo count = new DlogStatInfo();
//============== 日記數
count.setArticle(DiaryDAO.getDiaryCount(site));
//============== 日記評論數
count.setArticleReply(DiaryDAO.getDiaryReplyCount(site));
//============== 相片數
count.setPhoto(PhotoDAO.getPhotoCount(site));
//============== 相片評論數
count.setPhotoReply(PhotoDAO.getPhotoReplyCount(site));
//============== 論壇帖子數
count.setTopic(BBSTopicDAO.getTopicCount(site));
//============== 論壇評論數
count.setTopicReply(BBSReplyDAO.getReplyCount(site));
//============== 注冊用戶數
count.setUser(UserDAO.getUserCount(site));
//============== 注冊網站數
count.setSite(SiteDAO.getSiteCount());
return count;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -