亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? elantopicdaoimpl.java

?? struts+hibernate BBS mysql數(shù)據(jù)庫 功能基本齊全
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package com.elan.forum.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.elan.db.ElHbnDB;
import com.elan.forum.dao.TopicDAO;
import com.elan.forum.model.ForumTopic;
import com.elan.forum.model.Forumpiece;
import com.elan.forum.model.Forumtopicreply;
import com.elan.forum.model.Forumtopictype;
import com.elan.forum.model.Forummodule;
import com.elan.forum.model.view.Forumnewtopic;
import com.elan.forum.util.Constents;

public class ElanTopicDAOImpl implements TopicDAO {
	private static ElanTopicDAOImpl elanTopicDAOImpl = null;

	private ElanTopicDAOImpl() {
	}

	static {
		elanTopicDAOImpl = new ElanTopicDAOImpl();
	}

	public static ElanTopicDAOImpl newInstance() {
		return elanTopicDAOImpl;
	}

	public int addForumtopic(ForumTopic forumtopic) {
		return 0;
	}

	public int deleteForumtopic(int id) {
		return 0;
	}

	public int deleteForumtopic(ForumTopic forumtopic) {
		return 0;
	}

	public List<ForumTopic> getAllTopic() {
		List<ForumTopic> aList = null;
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery("from Forumtopic");
		aList = query.list();
		return aList;
	}

	public int modifyForumtopic(int id) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int modifyForumtopic(ForumTopic forumtopic) {
		// TODO Auto-generated method stub
		return 0;
	}

	public ForumTopic findForumtopic(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * 發(fā)表新文章 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#postTopic(com.elan.forum.model.Forumtopic)
	 */
	public int postTopic(ForumTopic topic) {
		Session session = ElHbnDB.getSession();
		session.save(topic);
		session.flush();
		return Constents.CURRENT_OPERATION_SUCCESS;
	}

	public Object[] getTopicById(int id) {
		Session session = ElHbnDB.getSession();
		Query query = session
				.createQuery("select id, title, text, createTime, click, reply, topicType, moduleId, moduleName, pieceId, pieceName, author from Forumtopic where id = "
						+ id);
		return (Object[]) query.list().get(0);
	}

	public List<Forumtopictype> getAllTopicType() {
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery("from Forumtopictype");
		return query.list();
	}

	public List<Forummodule> getForumModule() {
		Session session = ElHbnDB.getSession();
		String sql = "from Forummodule";
		Query query = session.createQuery(sql);
		return query.list();
	}

	/*
	 * 獲取Module信息,方法內(nèi)部自己處理事物,專門用于jsp 中直接調(diào)用 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#getForumModuleByTransaction()
	 */
	public List<Forummodule> getForumModuleByTransaction() {
		Session session = ElHbnDB.getSession();
		Transaction tx = session.beginTransaction();
		Query query;
		try {
			String sql = "from Forummodule";
			query = session.createQuery(sql);
			tx.commit();
		} catch (RuntimeException re) {
			// do something
			tx.rollback();
			return null;
		} finally {
			ElHbnDB.closeSession();
		}
		return query.list();
	}

	/*
	 * 獲取module文章,首頁不建議,因為他是返回很多個文章對象應(yīng)該采用getForumnewtopic方法獲取 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#getForumModuleTopic(java.util.HashMap)
	 */
	@SuppressWarnings("unchecked")
	public HashMap getForumModuleTopic(HashMap fmaMap) {
		Session session = ElHbnDB.getSession();
		Transaction tx = session.beginTransaction();
		List<Forummodule> mlist;
		try {
			String msql = "from Forummodule";
			String asql = "from Forummodule where id = ?";
			mlist = session.createQuery(msql).list();// m list
			for (int m = 0; m < mlist.size(); m++) {
				for (int i = 0; i < mlist.size(); i++) {
					Query query = session.createQuery(asql);
					query.setParameter(0, ((Forummodule) mlist.get(i)).getId());
					fmaMap.put(((Forummodule) mlist.get(m)).getName(), query
							.list());
				}
			}
		} catch (RuntimeException re) {
			// do something
			tx.rollback();
		} finally {
			ElHbnDB.closeSession();
		}
		return fmaMap;
	}

	/*
	 * 獲取mudule文章,只返回最新發(fā)表的文章 (non-Javadoc) 這里自己處理事物
	 * 
	 * @see com.elan.forum.dao.TopicDAO#getForumnewtopic()
	 */
	@SuppressWarnings("unchecked")
	public List<Forumnewtopic> getForumnewtopic() {
		Session session = ElHbnDB.getSession();
		Transaction tx = session.beginTransaction();
		try {
			String sql = "from Forumnewtopic";
			Query query = session.createQuery(sql);
			tx.commit();
			return query.list();
		} catch (RuntimeException re) {
			tx.rollback();
		} finally {
			ElHbnDB.closeSession();
		}
		return null;// error
	}

	public List<ForumTopic> findPiece(Integer pieceId) {
		List<ForumTopic> list = null;
		Session session = ElHbnDB.getSession();
		try {
			String hql = "from ForumTopic where pieceId = ?  and essence = 0 and top = 0 and locked = 0 order by id desc";
			Query query = session.createQuery(hql);
			query.setParameter(0, pieceId);
			list = query.list();
		} catch (RuntimeException re) {
			// to do
			re.printStackTrace();
		}
		return list;
	}

	public ForumTopic findPieceTopic(Integer topicId) {
		Session session = ElHbnDB.getSession();
		ForumTopic fa = null;
		try {
			String hql = "from ForumTopic where id = ? and locked = 0";
			Query query = session.createQuery(hql);
			query.setParameter(0, topicId);
			query.uniqueResult();
			fa = (ForumTopic) query.list().get(0);
			return fa;
		} catch (RuntimeException re) {
			re.printStackTrace();
		}
		return fa;
	}

	public List<Forumtopicreply> findTopicRegly(Integer topicId) {
		Session session = ElHbnDB.getSession();
		List<Forumtopicreply> list = null;
		try {
			String hql = "from Forumtopicreply where topicId = ? and locked = 0";
			Query query = session.createQuery(hql);
			query.setParameter(0, topicId);
			list = query.list();
			if (list == null) {
			}
			return list;
		} catch (RuntimeException re) {
			// to do
			re.printStackTrace();
		}
		return list;
	}

	/*
	 * 獲取最后回復(fù)的帖子 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#getLastTopicReplyById(java.lang.Integer)
	 */
	public Forumtopicreply getLastTopicReplyById(Integer topicReplyId) {
		Session session = ElHbnDB.getSession();
		List<Forumtopicreply> list = null;
		String hql = "select MAX(id) from Forumtopicreply where topicId = "
				+ topicReplyId + " and locked = 0";
		Integer id = (Integer) session.createQuery(hql).uniqueResult();
		Query query = session
				.createQuery("from Forumtopicreply where topicId = ? and id = ? and locked = 0");
		query.setParameter(0, topicReplyId);
		query.setParameter(1, id);
		list = (List<Forumtopicreply>) query.list();
		if (list.size() == 0) {
			return null;
		}
		return (Forumtopicreply) query.list().get(0);
	}

	/*
	 * 保存回復(fù)的帖子 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#replyTopic(com.elan.forum.model.Forumtopicreply)
	 */
	public boolean replyTopic(Forumtopicreply forumTopicReply) {
		Session session = ElHbnDB.getSession();
		try {
			session.save(forumTopicReply);
		} catch (RuntimeException re) {
			re.printStackTrace();
			return false;
		}
		return true;
	}

	/*
	 * 根據(jù)TopicReplyId查找回復(fù)帖子 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#findTopicReplyById(java.lang.Integer)
	 */

	public Forumtopicreply findTopicReplyById(Integer topicReplyId) {
		Session session = ElHbnDB.getSession();
		String hql = "from Forumtopicreply where id = ? and locked = 0";
		Query query = session.createQuery(hql);
		query.setParameter(0, topicReplyId);
		List<Forumtopicreply> list = query.list();
		if (list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

	/**
	 * 獲取全部的piece 下面的topic
	 * 
	 * @param pieceId
	 * @return
	 */
	public List getForumTopicByPieceId(Integer pieceId) {
		List list = null;
		Session session = ElHbnDB.getSession();
		String hql = "from ForumTopic where pieceId = ? and locked = 0";
		Query query = session.createQuery(hql);
		return query.list();
	}

	/**
	 * 根據(jù)pageSize獲取page獲取list
	 * 
	 * @param page
	 * @param pageSize
	 * @param pieceId
	 * @return
	 */
	public List<Forumtopicreply> getForumTopicByPieceId(Integer page,
			Integer pageSize, Integer pieceId) {
		List<Forumtopicreply> list = null;
		Session session = ElHbnDB.getSession();
		String hql = "From ForumTopic where pieceId = ? and essence = 0 and top = 0 and locked = 0 order by id desc";
		Query query = session.createQuery(hql);
		query.setParameter(0, pieceId);
		query.setFirstResult((page - 1) * pageSize);
		query.setMaxResults(pageSize);
		return query.list();
	}

	/**
	 * 獲取哪個piece有新帖子,以天為單位來計數(shù)時間間隔 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#getForumPieceIsNew()
	 */
	public byte[] getForumPieceIsNew() {
		byte[] isNew = null;
		Session session = ElHbnDB.getSession();
		Transaction tx = session.beginTransaction();
		try {
			Query query = session.createQuery("from Forumpiece ");
			List list = query.list();
			if (list.size() > 0) {
				isNew = new byte[list.size()];
			}
			for (int i = 0; i < list.size(); i++) {
				// isNew[i] = ((Forumpiece) list.get(i)).getIsNewTopic()
				// .booleanValue() ? Byte.valueOf("0").byteValue() :
				// Byte.valueOf("1").byteValue();
				if (((Forumpiece) list.get(i)).getIsNewTopic().booleanValue()) {
					isNew[i] = 1;
				} else {
					isNew[i] = 0;
				}
			}
		} catch (RuntimeException re) {
			tx.rollback();
			re.printStackTrace();
		} finally {
			ElHbnDB.closeSession();
		}
		return isNew;
	}

	/**
	 * 獲取總Topic的記錄 (non-Javadoc)
	 * 
	 * @see com.elan.forum.dao.TopicDAO#getForumTopicCount()
	 */
	public Long getForumTopicCount() {
		Session session = ElHbnDB.getSession();
		String hql = "select Count(*) From ForumTopic and locked = 0";
		Long l = ((Long) session.createQuery(hql).uniqueResult());
		return l;
	}

	/**
	 * 獲取pieceId下面的topic數(shù)
	 * 
	 * @param pieceId
	 * @return Long
	 */
	public Long getForumPieceTopicCountById(Integer pieceId) {
		Session session = ElHbnDB.getSession();
		String hql = "select Count(*) From ForumTopic where pieceId = "
				+ pieceId + " and locked = 0";
		Long l = ((Long) session.createQuery(hql).uniqueResult());
		return l;
	}

	/**
	 * 獲取頁數(shù)
	 * 
	 * @param pageSize
	 * @return
	 */
	public Long getForumPieceTopicCountById(Long pageSize) {
		Long pageCount = new Long(0);
		Long topicCount = getForumTopicCount();
		if (topicCount % pageSize == 0) {
			pageCount = topicCount / pageSize;
		} else {
			pageCount = (topicCount / pageSize) + 1;
		}
		return pageCount;
	}

	/**
	 * @param topicId
	 * @return Boolean
	 */
	public Boolean isNewReply(Integer topicId) {
		Boolean isNew = Boolean.valueOf(false);
		Session session = ElHbnDB.getSession();
		Forumtopicreply ftr = getLastTopicReplyById(topicId);
		Calendar cld = Calendar.getInstance();
		int theDay = cld.get(Calendar.DATE);
		Timestamp topicReplyDay = ftr.getReplyTime();
		int topicDay = topicReplyDay.getDate();
		if (theDay == topicDay) {
			isNew = Boolean.valueOf(true);
		} else {
			isNew = Boolean.valueOf(false);
		}
		return isNew;
	}

	/**
	 * @param ..
	 * @param ..
	 * @param ..
	 *            (non-Javadoc)
	 * @see com.elan.forum.dao.TopicDAO#getForumPieceTopic(java.lang.Integer,
	 *      java.lang.Integer, java.lang.Integer)
	 */
	public Map getForumPieceTopic(Integer page, Integer pageSize,
			Integer pieceId) {
		Map map = new HashMap();
		// 設(shè)置piece下面的topicCount
		Long topicCount = this.getForumPieceTopicCountById(pieceId);
		Long pageCount = new Long(0);
		map.put("topicCount", topicCount);

		if (0 == topicCount % pageSize) {
			pageCount = topicCount / pageSize;
		} else {
			pageCount = topicCount / pageSize + 1;
		}
		if (page > pageCount) {
			page = pageCount.intValue();
		}
		// 設(shè)置pageCount
		map.put("page", page);
		map.put("pageCount", pageCount);
		// 設(shè)置piece下面的topic
		List list = this.getForumTopicByPieceId(page, pageSize, pieceId);
		map.put("list", list);
		// 設(shè)置是否有新的回復(fù)
		Boolean[] isNewReplyArray = new Boolean[list.size()];
		for (int i = 0; i < list.size(); i++) {
			ForumTopic ft = (ForumTopic) list.get(i);
			Forumtopicreply ftr = getLastTopicReplyById(ft.getId());
			if (ftr != null) {
				isNewReplyArray[i] = isNewReply(ftr.getTopicId());
			} else {
				isNewReplyArray[i] = false;
			}

		}
		map.put("isNewReplyArray", isNewReplyArray);
		return map;
	}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
波多野结衣亚洲| 亚洲日本在线a| 国产精品久久久久一区二区三区 | 欧美激情一区二区在线| 免费精品99久久国产综合精品| 国产精品一区二区久久精品爱涩| 99热精品国产| 一区二区三区四区高清精品免费观看| 国产精品资源站在线| 精品国产一区二区三区av性色| 亚洲精品视频在线观看免费| 成人性生交大片免费看在线播放| 久久综合给合久久狠狠狠97色69| 美日韩一级片在线观看| 日韩欧美国产小视频| 日韩av电影免费观看高清完整版 | 一区二区三区四区在线播放 | 成人激情小说乱人伦| 欧美国产一区视频在线观看| 精品一区二区免费看| 精品蜜桃在线看| 国产suv精品一区二区6| 久久久久久久久久久久久女国产乱| 久久精品国内一区二区三区 | 久久激情综合网| 中文字幕一区二区三区色视频 | 日产欧产美韩系列久久99| 久久毛片高清国产| 91久久线看在观草草青青| 午夜亚洲福利老司机| 2020国产精品久久精品美国| 成人免费va视频| 亚洲网友自拍偷拍| 精品乱人伦小说| 91网站最新地址| 午夜视频一区二区| 精品99一区二区三区| 91免费观看视频在线| 看电影不卡的网站| 一区二区三区在线观看网站| 精品国产在天天线2019| 日本电影欧美片| www.亚洲免费av| 免费美女久久99| 亚洲国产日产av| 最新欧美精品一区二区三区| 日韩一区二区免费在线观看| 91捆绑美女网站| 国产二区国产一区在线观看| 日日夜夜精品免费视频| 亚洲欧洲美洲综合色网| 欧美激情一区二区三区全黄| 久久久国产一区二区三区四区小说| 欧美美女喷水视频| 欧美午夜不卡在线观看免费| 日本大香伊一区二区三区| 91浏览器在线视频| 99热精品一区二区| 在线视频中文字幕一区二区| av不卡免费在线观看| 成人高清在线视频| 99精品欧美一区二区蜜桃免费 | 欧美激情一二三区| 中文在线资源观看网站视频免费不卡| 精品久久久网站| 久久久精品国产免费观看同学| 3atv一区二区三区| 久久久欧美精品sm网站 | 国产成都精品91一区二区三| www.日本不卡| 欧美亚洲综合另类| 日韩欧美的一区二区| 日韩精品中文字幕一区| 3d成人h动漫网站入口| 日韩一级免费一区| 国产精品丝袜黑色高跟| 亚洲国产日韩a在线播放| 麻豆中文一区二区| 成人免费毛片嘿嘿连载视频| 日本高清不卡视频| 国产精品无人区| 日韩区在线观看| 中文子幕无线码一区tr| 天堂一区二区在线| 国产91精品精华液一区二区三区| 色香色香欲天天天影视综合网| 欧美一级理论片| 一二三四社区欧美黄| 国产乱码精品一品二品| 欧美日韩一本到| 亚洲欧美日韩一区二区三区在线观看| 亚洲成人黄色影院| 色综合天天综合网国产成人综合天| 欧美一区二区三区四区视频 | 久久精品一级爱片| 韩国三级中文字幕hd久久精品| 欧美电影免费提供在线观看| 久久综合九色综合97婷婷| 亚洲精品国产一区二区三区四区在线 | 国产精品嫩草影院com| 美国一区二区三区在线播放| 波多野结衣欧美| 中文一区二区完整视频在线观看| 蜜臀av一区二区在线观看| 宅男在线国产精品| 久久aⅴ国产欧美74aaa| 日韩亚洲欧美在线观看| 婷婷成人激情在线网| 欧美日韩精品欧美日韩精品| 亚洲国产视频网站| 26uuu色噜噜精品一区二区| 精品一二三四区| 久久久综合网站| 国产成人精品三级| 亚洲日本青草视频在线怡红院| 91视频免费看| 亚洲成人动漫在线免费观看| 欧美性xxxxxx少妇| 久久99久国产精品黄毛片色诱| 精品久久五月天| 99精品视频在线播放观看| 国产网站一区二区三区| 成人精品在线视频观看| 午夜影视日本亚洲欧洲精品| 欧美精品一区男女天堂| 成人v精品蜜桃久久一区| 亚洲一区在线视频| 久久精品亚洲麻豆av一区二区| 色婷婷亚洲精品| 日韩和的一区二区| 亚洲人成网站影音先锋播放| 欧美蜜桃一区二区三区| 精品在线免费观看| 亚洲黄色小视频| 国产欧美日韩综合精品一区二区| 欧美亚洲动漫另类| 国产精品亚洲第一区在线暖暖韩国| 亚洲综合免费观看高清完整版在线 | 欧美日韩国产综合草草| 国产精品亚洲第一区在线暖暖韩国| 一区二区三区免费观看| 国产精品情趣视频| 国产日韩欧美电影| www久久精品| 精品少妇一区二区三区| 欧美日韩国产片| 欧美日韩一本到| 制服丝袜日韩国产| 欧美专区在线观看一区| 99久久国产综合精品麻豆| 国产精品资源在线看| 国产99久久久精品| 9i看片成人免费高清| 91福利在线观看| 在线观看日韩一区| 在线播放亚洲一区| 在线电影欧美成精品| 欧美色综合网站| 欧美日韩亚洲综合| 欧美日韩一本到| 欧美一区二区三区啪啪| 久久众筹精品私拍模特| 国产夜色精品一区二区av| 欧美激情中文字幕一区二区| 久久精品一区四区| 一区二区三区波多野结衣在线观看| 日韩专区欧美专区| 一区二区三区毛片| 日韩高清在线不卡| 成熟亚洲日本毛茸茸凸凹| 国产suv精品一区二区6| 色哟哟国产精品| 7777精品伊人久久久大香线蕉的 | 精品国产伦一区二区三区免费| 在线免费观看不卡av| 狠狠网亚洲精品| 另类小说综合欧美亚洲| 日韩二区三区四区| 免费精品视频在线| 另类的小说在线视频另类成人小视频在线 | 欧美在线小视频| 欧美日精品一区视频| 91视视频在线观看入口直接观看www | 五月激情综合婷婷| 国产福利视频一区二区三区| jizz一区二区| 欧洲激情一区二区| 91麻豆精品国产91久久久更新时间| 91精品视频网| 久久久精品欧美丰满| 亚洲欧美一区二区三区极速播放 | 成人一区二区三区在线观看| 91一区二区在线| 欧美日韩国产综合一区二区| 日韩小视频在线观看专区| 精品盗摄一区二区三区| 亚洲人午夜精品天堂一二香蕉| 亚洲一区免费在线观看| 亚洲激情一二三区| 国产精品一线二线三线|