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

📄 articlebiz.java

📁 一个不错的bbs论坛系统.对初学者很有帮助
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public static List getEliteArticle(int size){
		
		try {
			return artdao.getEliteArticle(size);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getEliteArticle(int size):\n" + e.toString());
		}
		return null;
	}
	/** 取得论坛最新推荐帖子列表
	 * @param size 显示的总数
	 * @return 最新推荐帖子列表
	 */
	public static List getComArticle(int size){
		
		try {
			return artdao.getComArticle(size);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getComArticle(int size):\n" + e.toString());
		}
		return null;
	}
	/**
	 * @return 论坛总固顶帖子列表
	 */
	public static List getAllTop(){
		
		try {
			return artdao.getAllTop();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getAllTop():\n" + e.toString());
		}
		return null;
	}
	/**
	 * @param classId 区论坛Id
	 * @return 论坛区论坛固顶帖子列表
	 */
	public static List getClassTop(int classId){
		
		try {
			return artdao.getClassTop(classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getClassTop(int classId):\n" + e.toString());
		}
		return null;
	}
	/**
	 * @param forumId 论坛Id
	 * @return 论坛固顶帖子列表
	 */
	public static List getForumTop(int forumId){
		
		try {
			return artdao.getForumTop(forumId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getForumTop(int forumId):\n" + e.toString());
		}
		return null;
	}
	/** 取得论坛精华帖子列表
	 * @param fpageMap 论坛Id,分页起始位置和大小
	 * @return 论坛精华帖子列表
	 */
	public static List getForumElite(HashMap fpageMap){
		
		try {
			return artdao.getForumElite(fpageMap);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getForumElite(fpageMap):\n" + e.toString());
		}
		return null;
	}
	
	/** 取得论坛非固顶帖子列表
	 * @param fpageMap 论坛Id,分页起始位置和大小
	 * @return 论坛非固顶帖子列表
	 */
	public static List getForumArt(HashMap fpageMap){
		
		try {
			return artdao.getForumArt(fpageMap);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getForumArt(fpageMap):\n" + e.toString());
		}
		return null;
	}
	
	/** 取得论坛精华帖子总数
	 * @param forumId 论坛Id
	 * @return 论坛精华帖子总数
	 */
	public static int getForumEliteC(int forumId){
		
		try {
			return artdao.getForumEliteC(forumId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getForumEliteC(forumId):\n" + e.toString());
		}
		return 0;
	}
	/** 取得论坛帖子总数
	 * @param forumId 论坛Id
	 * @return 论坛帖子总数
	 */
	public static int getForumArtC(int forumId){
		
		try {
			return artdao.getForumArtC(forumId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getForumArtC(forumId):\n" + e.toString());
		}
		return 0;
	}
	/** 取得论坛非固顶帖子总数
	 * @param forumId 论坛Id
	 * @return 论坛非固顶帖子总数
	 */
	public static int getFmNoTopArtC(int forumId){
		
		try {
			return artdao.getForumNoTopC(forumId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getFmNoTopArtC(int forumId):\n" + e.toString());
		}
		return 0;
	}
	/** 增加某帖子的点击数一次
	 * @param artId 帖子Id
	 */
	public static void addOneHitTime(int artId){
		
		try {
			artdao.addOneHitTime(artId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke addOneHitTime(artId):\n" + e.toString());
		}
		return;
	}
	
	/** 取得今天所有发表帖子数
	 * @return 今天发表帖子数
	 */
	public static int getTodayCount(){
		
		try {
			return artdao.getTodayCount();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getTodayCount():\n" + e.toString());
		}
		return 0;
	}
	/** 取得昨天所有发表帖子数
	 * @return 昨天发表帖子数
	 */
	public static int getYesdayCount(){
		
		try {
			return artdao.getYesdayCount();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getYesdayCount():\n" + e.toString());
		}
		return 0;
	}
	
	/** 取得昨天某论坛发表帖子数
	 * @param forumId 论坛Id
	 * @return 昨天发表帖子数
	 */
	public static int getYesdayForumC(int forumId){
		
		try {
			artdao.getForumYesdayC(forumId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getForumYesdayC(forumId):\n" + e.toString());
		}
		return 0;
	}
	
	/** 移动论坛帖子
	 * @param classId 目标区论坛Id
	 * @param movefId 目标论坛Id
	 * @param artId 帖子Id
	 * @param forumId 原论坛Id
	 * @return true:成功 false:失败
	 */
	public static boolean moveArt(int classId,int movefId,int artId,int forumId){
		boolean move = false;
		HashMap<String,Integer> moveMap = new HashMap<String,Integer>();
		moveMap.put("classId",classId);
		moveMap.put("forumId",movefId);
		moveMap.put("artId",artId);
		boolean isToday = isTodayArt(artId);
		try {
			int fmArtId = artdao.getForumLastArt(movefId).getId();	   // 取得目标论坛最新文章Id
			move = artdao.moveArticle(moveMap);						  // 开始移动
			if(move){
				if(artId==ForumBiz.getForumLArtId(forumId))  		 // 已经删除的文章是本论坛的最新文章
					upForumLastArt(forumId,true,isToday);			// 移动的帖子只能够是主题贴
				else
					ForumBiz.delArticle(forumId,true,isToday);    // 更新原论坛统计信息(主要是帖子数目的更新)
				ArticleDto curArt = artdao.getArticle(artId);
				
				if(artId>fmArtId){ // 移动的文章比目标论坛最新文章要新
					ForumArtPost fArtPost = new ForumArtPostIm();    
					String title = "";
					int titlelength = Constants.titlelength;
					fArtPost.setId(movefId);
					title = curArt.getTitle();
					if(title.length()<=titlelength)
						fArtPost.setLastart(title);
					else
						fArtPost.setLastart(title.substring(0,titlelength)+"···");
					fArtPost.setLastartid(curArt.getId());
					fArtPost.setLastuserid(curArt.getUserid());
					fArtPost.setLastuser(curArt.getUser());
					fArtPost.setLasttime(curArt.getPosttime());
					ForumBiz.forumMoveArt(fArtPost,isToday);
				}
			}else{
				bbslog.error("Move Article unsuccessfully!The article id is:"+artId);
			}
		}catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke moveArt(classId,movefId,artId,forumId):\n" + e.toString());
		}
		return move;
	}
	
	/** 论坛帖子置顶操作
	 * @param artId 帖子Id
	 * @param topId 置顶类型
	 */
	public static void setTop(int artId,String topId){
		HashMap topMap = new HashMap();
		topMap.put("topId",topId);
		topMap.put("artId",artId);
		try {
			artdao.setArtTop(topMap);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke setTop(int artId,int topId):\n" + e.toString());
		}
		return ;
	}
	/** 论坛帖子精华操作
	 * @param artId 帖子Id
	 * @param userId 帖子作者
	 * @param flag true:设置精华 false:取消精华
	 */
	public static void setElite(int artId,int userId,boolean flag){
		WealthDtoIm wealth = null;
		try {
			artdao.setElite(artId,flag);
			if(flag){
				wealth = (WealthDtoIm) WealthBiz.getArtEliteWth();
				wealth.setId(userId);
				UserBiz.postArticle(wealth,3); 
			}else{
				wealth = (WealthDtoIm) WealthBiz.getArtEliteWth();
				wealth.setId(userId);
				UserBiz.postArticle(wealth,6); 
			}
				
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke setElite(artId,flag):\n" + e.toString());
		}
		return ;
	}
	/** 论坛帖子推荐操作
	 * @param artId 帖子Id
	 * @param flag true:设置推荐 false:取消推荐
	 */
	public static void setComm(int artId,boolean flag){
		
		try {
			artdao.setCommend(artId,flag);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke setComm(int artId,boolean flag):\n" + e.toString());
		}
		return ;
	}
	/** 论坛帖子锁定操作
	 * @param artId 帖子Id
	 * @param flag true:设置锁定 false:取消锁定
	 */
	public static void setLock(int artId,boolean flag){
		
		try {
			artdao.setLock(artId,flag);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke setLock(int artId,boolean flag):\n" + e.toString());
		}
		return ;
	}
	
	/** 取得用户贴子总数
	 * @param userId 用户Id
	 * @param i 0:主题贴 1:回复贴
	 * @return 用户贴子总数
	 */
	public static int getUserArtCount(int userId,int i){
		
		try {
			return artdao.getUserArtcount(userId,i);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getUserArtCount(int userId):\n" + e.toString());
		}
		return 0;
	}
	/** 取得用户贴子列表
	 * @param artpage 用户Id,起始终止页
	 * @param i 0:主题贴 1:回复贴
	 * @return 用户贴子列表
	 */
	public static List getUserArt(HashMap artpage,int i){
		
		try {
			return artdao.getUserArt(artpage,i);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getUserArt(int userId):\n" + e.toString());
		}
		return null;
	}
	/**
	 *  判断某帖子是否为今日帖子
	 * @param artId 帖子Id
	 * @return trur:今日帖  false:非今日帖
	 */
	private static boolean isTodayArt(int artId){
		try {
			String curDate = DateUtils.getCurFormatDate(Constants.dateFS);
			String postStr = DateUtils.getDate2Str(Constants.dateFS, artdao.getArtPostTime(artId));
			return curDate.equals(postStr);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke isTodayArt(int artId):\n" + e.toString());
		}
		return false;
	}
	
	/** 取得所有帖子建立系统索引
	 * @return 系统所有帖子
	 * @throws SQLException
	 */
	public static List getSearchIndexArt(){
		
		try {
			return artdao.getArtForSearchIndex();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getSearchIndexArt():\n" + e.toString());
		}
		return null;
	}
	
	/** 当移动论坛后,属于该论坛的所有帖子都要移动
	 * @param forumId 论坛Id
	 * @param classId 目标区论坛Id
	 * @return true:成功 false:失败
	 * @throws SQLException
	 */
	public static boolean moveForum(int forumId,int classId){
		boolean flag = true;
		try {
			flag = artdao.moveForum(forumId, classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke isTodayArt(int artId):\n" + e.toString());
			flag = false;
		}
		return flag;
	}
}

⌨️ 快捷键说明

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