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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? elantopicdaoimpl.java

?? struts+hibernate BBS mysql數據庫 功能基本齊全
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
	/**
	 * 獲取topicID下回復的條數
	 * 
	 * @param
	 * @return Long
	 */
	public Long getForumTopicReplyCountById(Integer topicId) {
		Session session = ElHbnDB.getSession();
		String hql = "select Count(*) From Forumtopicreply where topicId = "
				+ topicId + "and locked = 0";
		Long l = ((Long) session.createQuery(hql).uniqueResult());
		return l;
	}


	/**
	 * 給出topicId,返回所有的topicreply
	 * @param topicId
	 * @return list<Forumtopicreply>
	 */
	public List<Forumtopicreply> getForumTopicReplyById(Integer topicId) {
		Session session = ElHbnDB.getSession();
		String hql = "from forumtopicreply where topicId = ? and locked = 0";
		Query query = session.createQuery(hql);
		query.setParameter(0, topicId);
		return query.list();
	}
	
	/**
	 * 返回給定叁數信息返回一定大小的topicreply list
	 * 根據本人在以前測試一個用hibernate 的setM...setF....來分頁,
	 * 記憶中比MYSQL limit 分頁的數據塊
	 * 所以采用hibernate分頁
	 * @param page 第幾頁開始
	 * @param pageSize 頁碼的大小
	 * @param topicId 哪個topic下面
	 * @return List<Forumtopicreply> 
	 */
	public List<Forumtopicreply> getForumTopicReplyById(Integer page, Integer pageSize, Integer topicId) {
		Session session = ElHbnDB.getSession();
		String hql = "From Forumtopicreply where topicId = ? and locked = 0";
		Query query = session.createQuery(hql);
		query.setParameter(0, topicId);
		query.setFirstResult((page - 1) * pageSize);
		query.setMaxResults(pageSize);
		return query.list();
	}
	
	/**
	 * 成員 topicCount 并不包括topic主題,只包括reply的topic
	 * map: 1)topicCount
	 * 		2)page
	 * 		3)pageCount
	 * 		4)replyList
	 * 		5)fuList   回復的作者
	 * @param page 第幾頁開始
	 * @param pageSize 頁碼的大小
	 * @param topicId 哪個topic下面
	 * @return Map
	 * (non-Javadoc)
	 * @see com.elan.forum.dao.TopicDAO#getForumTopicReply(java.lang.Integer, java.lang.Integer, java.lang.Integer)
	 */
	public Map getForumTopicReply(Integer page, Integer pageSize, Integer topicId) {
		Map map = new HashMap();
		// 設置這個topic下面的的回復的topicReplyCount
		Long topicCount = this.getForumTopicReplyCountById(topicId);
		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();
		}
		//..
		map.put("page", page);
		// 設置pageCount,一共有多少頁
		map.put("pageCount", pageCount);
		// 設置topic下面的topicReply
		List<Forumtopicreply> list = this.getForumTopicReplyById(page, pageSize, topicId);
		map.put("replyList", list);
		return map;
	}

	public boolean saveTopic(ForumTopic forumTopic) {
		Session session = ElHbnDB.getSession();
		session.save(forumTopic);
		return true;
	}

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

	/*
	 * 獲取新的帖子
	 * (non-Javadoc)
	 * @see com.elan.forum.dao.TopicDAO#getNewPostTopic(java.lang.Integer)
	 */
	public List<ForumTopic> getNewPostTopic(Integer pieceId, Integer page, Integer pageSize) {
		Session session = ElHbnDB.getSession();
		String hql = "From ForumTopic where 1 = 1 and";
		if(pieceId != null) {
			hql += " pieceId = ? and";
		}
		hql += " locked = 0 order by id desc";
		Query query = session.createQuery(hql);
		if(pieceId != null) {
			query.setParameter(0, pieceId);
		}
		if(page != null && page.intValue() > 1) {
			query.setFirstResult((page - 1) * pageSize);
		}
		if(pageSize != null && pageSize > -1) {
			query.setMaxResults(pageSize);
		}
		return query.list();
	}

	/**
	 * 獲取最熱門的帖子
	 */
	public List<ForumTopic> getHotTopic(Integer pieceId, Integer page,
			Integer pageSize) {
		boolean isPieceId = false;
		String hql = "From ForumTopic";
		if(pieceId != null && pieceId.intValue() > 0) {
			hql += " where pieceId = ? and hot = 1";
			isPieceId = true;
		} else {
			hql += " where hot = 1";
		}
		hql += " and locked = 0 order by id desc";
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery(hql);
		if(isPieceId) {
			query.setParameter(0, pieceId);
		}
		if(pageSize != null && pageSize.intValue() > -1) {
			query.setMaxResults(pageSize);
		}
		return query.list();
	}

	public Forumpiece getForumPieceById(Integer pieceId) {
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery("From Forumpiece where id = ?");
		query.setParameter(0, pieceId);
		List<Forumpiece> list = query.list();
		if(list.size() > 0) {
			return list.get(0);
		}
		return null;
	}

	public List<Forummodule> getModule() {
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery("From Forummodule");
		List<Forummodule> list = query.list();
		return list;
	}

	public List<Forumpiece> getPiece() {
		Session session  = ElHbnDB.getSession();
		Query query = session.createQuery("From Forumpiece");
		List<Forumpiece> list = query.list();
		return list;
	}

	public Map<String, Object> search(Integer moduleId, Integer pieceId,
			Integer topicId, Integer hotReal, String topicName, String author,
			Timestamp startTime, Timestamp endTime, Integer precision, Integer page, Integer pageSize) {
		//采用hql實現,也可以采用QBC語句實現
		Integer topicCount = 0;
		Map<String, Object> map = null;
		Session session = ElHbnDB.getSession();
		String hql = this.createHql(moduleId, pieceId, topicId, hotReal, topicName, author, startTime, endTime, precision, page, pageSize, topicCount);
		System.out.println(hql);
		topicCount = Integer.valueOf(((Long) session.createQuery("select Count(*) " + hql).uniqueResult()).intValue());
		Integer pageCount = 0;
		if(topicCount % pageSize == 0) {
			pageCount = topicCount / pageSize;
		} else {
			pageCount = topicCount / pageSize + 1;
		}
		if(page < 0) {
			page = 1;
		}else if(page > pageCount) {
			page = pageCount;
		}
		Query query = session.createQuery(hql);
		query.setFirstResult((page - 1) * pageSize);
		query.setMaxResults(pageSize);
		List<ForumTopic> listTopic = query.list();
		if(listTopic.size() > 0) {
			map = new HashMap<String, Object>();
			map.put("page", page);//當前頁
			map.put("pageSize", pageSize);//頁碼大小
			map.put("topicCount", topicCount);//總帖子數
			map.put("pageCount", pageCount);//總頁數
			map.put("listTopic", listTopic);//分過頁的帖子列表
			return map;
		}
		return null;
	}
	
	
	private String createHql(Integer moduleId, Integer pieceId,
			Integer topicId, Integer hotReal, String topicName, String author,
			Timestamp startTime, Timestamp endTime, Integer precision, Integer page, Integer pageSize, Integer topicCount) {
		String hql = "From ForumTopic where 1 = 1  and locked = 0 ";
		if(topicId != null && topicId.intValue() > 0) {
			hql += " and id = " + topicId;
		} 
		if(pieceId != null && pieceId.intValue() > 0) {
			hql += " and pieceId = "+ pieceId;
		}
		if(moduleId != null && moduleId.intValue() > 0) {
			hql += " and moduleId = " + moduleId;
		}
		if(hotReal != null && (hotReal.intValue() == 2 || hotReal.intValue() == 1)) {
			if(1 == hotReal.intValue()) {
				hql += " and hot = 1";
			} else if(2 == hotReal.intValue()) { //精華
				hql += " and essence = 1";
			}
		}
		if(author != null && !"".equals(author.trim())) {
			hql += " and author = '" + author + "'";
		}
		if(startTime != null && endTime != null) {
			hql += " and createTime between '" + startTime + "' and '" + endTime+ "'";
		}
		if(topicName != null && !"".equals(topicName.trim())) {
			if(precision != null && 1 == precision.intValue()) { //精確
				hql += " and title = '" + topicName + "'";
			} else if(precision != null && 2 == precision.intValue()) {
				hql += " and title like '%" + topicName + "%'";
			}
		}
		hql += " order by id desc";
		return hql;
	}

	public List<ForumTopic> getTopTopic(Integer pieceId) {
		Session session  =ElHbnDB.getSession();
		String hql = "From ForumTopic where pieceId = ? and top = 1 and locked = 0";
		Query query = session.createQuery(hql);
		query.setParameter(0, pieceId);
		List<ForumTopic> list = query.list();
		if(list.size() > 0) {
			return list;
		}
		return null;
	}

	/* 
	 * 獲取精華帖子
	 * (non-Javadoc)
	 * @see com.elan.forum.dao.TopicDAO#getEssenceTopic(java.lang.Integer)
	 */
	public List<ForumTopic> getEssenceTopic(Integer pieceId) {
		Session session = ElHbnDB.getSession();
		String hql = null;
		boolean isEmptyPieceId = false;
		if(pieceId != null) {
			hql = "From ForumTopic where pieceId = ? and essence = 1 and locked = 0";
		} else {
			hql = "From ForumTopic where essence = 1 and locked = 0";
			isEmptyPieceId = true;
		}
		Query query = session.createQuery(hql);
		if(!isEmptyPieceId) {
			query.setParameter(0, pieceId);
		}
		List<ForumTopic> list = query.list();
		if(list.size() > 0) {
			return list;
		} 
		return null;
	}

	public Long getTopicCountById(Integer pieceId) {
		Session session = ElHbnDB.getSession();
		String hql = "SELECT COUNT(*) From ForumTopic where pieceId = ? and locked = 0";
		Query query = session.createQuery(hql);
		query.setParameter(0, pieceId);
		return (Long) query.uniqueResult();
	}

	public Long getTopicCountByHql(String hql) {
		Session session = ElHbnDB.getSession();
		if(hql == null) {
			return new Long(0);
		}
		Query query = session.createQuery(hql);
		return (Long) query.uniqueResult();
	}

	public List<ForumTopic> getTopicByHql(String hqlStr) {
		Session session = ElHbnDB.getSession();
		String hql ="From ForumTopic where 1 = 1";
		List list ;
		if(null != hqlStr) {
			hql += hqlStr;
		}
		Query query = session.createQuery(hql);
		list = query.list();
		return list;
	}
	public List<ForumTopic> getUserTopic(Integer id, Integer page, Integer pageSize) {
		Session session = ElHbnDB.getSession();
		List<ForumTopic> list;
		String hql = "From ForumTopic where  authorId = ? and locked = 0 order by id desc";
		Query query = session.createQuery(hql);
		query.setParameter(0, id);
		query.setFirstResult((page - 1) * pageSize);
		query.setMaxResults(pageSize);
		list = query.list();
		return list;
	}

	public Integer getCount(Integer authorId) {
		Session session = ElHbnDB.getSession();
		String hql = "Select Count(*) From ForumTopic where authorId = ? and locked = 0  order by id";
		Query query = session.createQuery(hql);
		query.setParameter(0, authorId);
		Long l = (Long) query.uniqueResult();
		Integer count = Integer.valueOf(l.intValue());
		return count;
	}

	public Integer getCount(String hql) {
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery(hql);
		Long l = (Long) query.uniqueResult();
		Integer count = Integer.valueOf(l.intValue());
		return count;
	}
	
	public  Integer getCount(String hql, int paras, String [] values) {
		Session session = ElHbnDB.getSession();
		Query query = session.createQuery(hql);
		if(paras > 0) {
			for(int i = 0 ; i < paras; i++) {
				query.setParameter(i, values[i]);
			}
		}
		Long l = (Long) query.uniqueResult();
		Integer count = Integer.valueOf(l.intValue());
		return count;
	}

	public Integer getHotTopicCount(Integer id) {
		String hql = "select Count(*) from ForumTopic where authorId = ? and Hot = 1 and locked = 0";
		String [] values = new String[]{"" +id};
		return this.getCount(hql, values.length, values);
	}
	public List<ForumTopic> getTopic(String hql, int paras, String [] values, Integer page, Integer pageSize) {
		Session session = ElHbnDB.getSession();
		List<ForumTopic> list;
		Query query = session.createQuery(hql);
		if(paras > 0) {
			for(int i = 0 ; i < paras; i++) {
				query.setParameter(i, values[i]);
			}
		}
		if(null != page && null != pageSize) {
			query.setFirstResult((page - 1) * pageSize);
			query.setMaxResults(pageSize);
		}
		list = (List<ForumTopic>)query.list();
		return list;
	}
	public List<ForumTopic> getUserHotTopic(Integer id, Integer page,
			Integer pageSize) {
		String hql = "From ForumTopic where authorId = ? and Hot = 1 and locked = 0 order by id desc";
		String [] values = new String[]{"" + id};
		return this.getTopic(hql, values.length, values, page, pageSize);
	}

	public Integer getEssenceTopicCount(Integer id) {
		String hql = "select Count(*) from ForumTopic where authorId = ? and essence = 1 and locked = 0";
		String [] values = new String[]{"" +id};
		return this.getCount(hql, values.length, values);
	}

	public List<ForumTopic> getUserEssenceTopic(Integer id, Integer page,
			Integer pageSize) {
		String hql = "From ForumTopic where authorId = ? and essence = 1 and locked = 0 order by id desc";
		String [] values = new String[]{"" + id};
		return this.getTopic(hql, values.length, values, page, pageSize);
	}

	/* 
	 * 這里通過connection連接,要過Hibernate
	 * (non-Javadoc)
	 * @see com.elan.forum.dao.TopicDAO#getUserReplyTopic(java.lang.Integer)
	 */
	public Integer getUserReplyTopic(Integer id) {
		String sql = "select count(*) as count from (select * from forumtopicreply where authorId = ? and locked = 0  group by topicId) as frt";
		Session session = ElHbnDB.getSession();
		Integer count = 0;
		Connection conn = session.connection();
		PreparedStatement pStmt = null;
		ResultSet rs = null;
		try {
			pStmt = conn.prepareStatement(sql);
			pStmt.setInt(1, id);
			rs = pStmt.executeQuery();
			conn.commit();
			if(null != rs && rs.next()) {
				count = rs.getInt("count");
			}
			conn.setAutoCommit(false);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return count;
	}

	/* 
	 * 獲取用戶回復過的帖子
	 * @see com.elan.forum.dao.TopicDAO#getUserReplyed(java.lang.Integer, java.lang.Integer, java.lang.Integer)
	 */
	public List<ForumTopic> getUserReplyed(Integer id, Integer page,
			Integer pageSize) {
		String hql = "select topicId From Forumtopicreply where authorId = ? and locked = 0 group by topicId order by id desc";
		String hqlForumTopic = "From ForumTopic as ft where id in(";
		Session session = ElHbnDB.getSession();
		List<Object> list;
		Integer [] ArrTopicId;
		Query query = session.createQuery(hql);
		query.setParameter(0, id);
		query.setFirstResult((page - 1) * pageSize);
		query.setMaxResults(pageSize);
		list = query.list();
		for(int i = 0; i < list.size(); i++) {
			hqlForumTopic += (Integer)list.get(i) + ",";
		}
		hqlForumTopic +="-1) and locked = 0 order by id desc";
		List<ForumTopic> listFt;
		query =  session.createQuery(hqlForumTopic);
		//query.setFirstResult((page - 1) * pageSize);
		query.setMaxResults(pageSize);
		listFt = query.list();
		System.out.println(hqlForumTopic);
		System.out.println("第:" + (page - 1) * pageSize);
		System.out.println("一起返回:" + pageSize + "條");
		for(int i = 0; i < listFt.size(); i++) {
			System.out.println(((ForumTopic)listFt.get(i)).getTitle());
		}
		return listFt;
	}
	
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区不卡视频在线观看| 色综合天天天天做夜夜夜夜做| 精品福利二区三区| 国产成人8x视频一区二区| 久久女同精品一区二区| 99久久伊人网影院| 亚洲精品国产无天堂网2021| 国产老肥熟一区二区三区| 亚洲人成7777| 91免费版在线看| av中文字幕亚洲| 午夜精品成人在线视频| 日韩免费高清视频| 欧美日本视频在线| 欧美日韩一区三区| 3d动漫精品啪啪一区二区竹菊| 欧美日韩免费视频| 欧美一区二区福利在线| 日韩三级免费观看| 26uuu亚洲综合色| 亚洲国产精品激情在线观看| 国产午夜亚洲精品午夜鲁丝片| 中文字幕乱码久久午夜不卡| 亚洲婷婷综合久久一本伊一区| 国产精品国产自产拍高清av王其| 中文字幕一区二区三区不卡在线 | 欧美日韩一区久久| 欧美性xxxxxx少妇| 91精品国产欧美一区二区成人| 5858s免费视频成人| 欧美一区二区三区日韩| 精品国产一二三| 精品国产乱码久久久久久免费| 日本一区二区电影| 亚洲一区二区欧美激情| 视频在线观看91| 久久99久久99精品免视看婷婷| 成人污视频在线观看| 色八戒一区二区三区| 制服丝袜中文字幕亚洲| 精品免费国产二区三区| 综合激情成人伊人| 午夜国产不卡在线观看视频| 精品亚洲国产成人av制服丝袜| 国产精品白丝av| 欧洲色大大久久| 五月天亚洲精品| 黄色小说综合网站| 色综合久久久久综合| 麻豆国产精品777777在线| 久久99精品久久久久| 成人午夜免费视频| 国产91精品露脸国语对白| 色八戒一区二区三区| 久久精品欧美日韩| 亚洲男人都懂的| 久久精品国产成人一区二区三区 | 国产精品嫩草影院av蜜臀| 亚洲影视在线播放| 亚洲国产成人高清精品| 国产a级毛片一区| 欧美人xxxx| 中文字幕中文字幕中文字幕亚洲无线| 香蕉影视欧美成人| 国产美女一区二区| 欧美日韩国产片| 亚洲丝袜制服诱惑| 国产高清久久久久| 在线不卡中文字幕播放| 国产精品国产三级国产a| 蜜乳av一区二区| 91福利资源站| 中文字幕国产一区| 韩国精品主播一区二区在线观看| 99久久精品国产导航| 欧美大片在线观看一区| 亚洲一区二区三区美女| fc2成人免费人成在线观看播放| 日韩网站在线看片你懂的| 亚洲最快最全在线视频| 成人av影院在线| 久久奇米777| 久久99精品国产91久久来源| 欧美三级电影网站| 亚洲综合视频在线| 9i在线看片成人免费| 久久精品一级爱片| 国产做a爰片久久毛片| 欧美一卡二卡在线观看| 亚州成人在线电影| 欧美日本不卡视频| 亚洲国产wwwccc36天堂| 91九色02白丝porn| 一区二区在线电影| 99re亚洲国产精品| 国产精品人成在线观看免费 | 欧美日韩欧美一区二区| 一区二区三区不卡视频| 成人黄色免费短视频| 国产午夜亚洲精品午夜鲁丝片| 国产在线精品一区二区夜色| 精品少妇一区二区三区免费观看 | 日韩电影网1区2区| 欧美日韩三级视频| 最好看的中文字幕久久| 99免费精品视频| 亚洲人成影院在线观看| 99久久国产免费看| 亚洲日韩欧美一区二区在线| 成人教育av在线| 中文字幕视频一区| 欧美专区日韩专区| 亚洲精品国产精华液| 欧美亚洲动漫另类| 午夜电影网一区| 欧美一区二区福利视频| 国产一区二区三区四区五区入口 | 欧美一区二区成人| 精品一二线国产| 久久影院电视剧免费观看| 精品亚洲成a人在线观看| 国产欧美日韩三区| 99精品国产视频| 亚洲国产va精品久久久不卡综合| 欧美人妇做爰xxxⅹ性高电影| 麻豆免费精品视频| 久久精品夜夜夜夜久久| 91亚洲精品久久久蜜桃| 玉足女爽爽91| 7799精品视频| 激情深爱一区二区| 国产精品系列在线| 欧美色涩在线第一页| 免费观看成人鲁鲁鲁鲁鲁视频| 精品国产人成亚洲区| 成人午夜视频在线观看| 夜夜精品浪潮av一区二区三区| 日韩三级.com| 成人一区二区在线观看| 一区二区三区在线视频播放| 日韩一区二区三区四区五区六区| 国产黄人亚洲片| 亚洲午夜久久久久久久久电影院| 91精品蜜臀在线一区尤物| 国产剧情一区二区| 亚洲国产精品ⅴa在线观看| 欧美午夜理伦三级在线观看| 五月综合激情日本mⅴ| 国产清纯白嫩初高生在线观看91 | 日韩中文字幕区一区有砖一区 | 美女网站在线免费欧美精品| 中文字幕国产一区| 5858s免费视频成人| 成人免费视频视频在线观看免费 | 另类小说视频一区二区| 国产精品美女一区二区在线观看| 欧美在线观看禁18| 国产在线日韩欧美| 亚洲国产精品一区二区www在线| 欧美精品一区二区三区蜜桃| 色综合色狠狠综合色| 激情欧美一区二区三区在线观看| 亚洲六月丁香色婷婷综合久久| 日韩欧美激情四射| 日本韩国一区二区| 国产精品资源在线观看| 亚洲成av人在线观看| 国产精品美女一区二区三区| 欧美大片在线观看| 欧美色窝79yyyycom| 国产suv精品一区二区三区| 午夜精品视频一区| 亚洲人亚洲人成电影网站色| 精品99一区二区三区| 欧美日韩精品免费| 91影视在线播放| 国产美女一区二区三区| 日本色综合中文字幕| 亚洲自拍另类综合| 国产精品久久久久久久久免费相片| 日韩午夜中文字幕| 欧美日韩精品是欧美日韩精品| www.99精品| 成人精品国产免费网站| 久久se精品一区精品二区| 亚瑟在线精品视频| 亚洲一区二区三区在线看| 国产精品久久久久久久久图文区| 久久久五月婷婷| 精品国产a毛片| 欧美变态tickling挠脚心| 欧美日本国产一区| 欧美日韩在线观看一区二区 | 久久婷婷一区二区三区| 欧美一区二区精品在线| 欧美精品vⅰdeose4hd| 欧美三级日韩三级国产三级| 在线观看成人免费视频| 99久久精品一区二区| 成人av中文字幕|