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

📄 classbiz.java

📁 一个不错的bbs论坛系统.对初学者很有帮助
💻 JAVA
字号:
package com.yhbbs.yhclass.biz;
import java.sql.SQLException;
import java.util.List;
import org.apache.log4j.Logger;

import com.yhbbs.user.biz.UserBiz;
import com.yhbbs.utils.StringUtils;
import com.yhbbs.yhclass.dao.ClassDaoIm;
import com.yhbbs.yhclass.itface.BbsClass;
import com.yhbbs.yhclass.itface.ClassDao;

/**
 * <p>Title:区论坛列表相关操作</p>
 * <li>	区论坛列表的相关操作
 * <p>Company: www.yyhweb.com</p>
 * <br><b>CopyRight: yyhweb[由由华网]</b>
 * @author stephen
 * @version YHBBS-2.0
 */
public class ClassBiz {
	
	private static Logger bbslog = Logger.getLogger(ClassBiz.class);
	
	private static ClassDao classdao = ClassDaoIm.getInstance();
	
	/** 取得区论坛名称
	 * @param classId 区论坛Id
	 * @return 区论坛名称
	 */
	public static String getClassName(int classId){
		
		try {
			return classdao.getClassName(classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getClassName(classId):\n" + e.toString());
		}
		return "";
	}
	
	/** 判断用户是否为区版主
	 * @param classId 区论坛Id
	 * @param userName 用户名称
	 * @return 区论坛名称
	 */
	public static boolean isClassAdmin(int classId,String userName){
		String admin = "";
		try {
			admin =  classdao.getClassAdmin(classId);
			return admin.indexOf(userName)!=-1;
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke isClassAdmin(int classId,String userName):\n" + e.toString());
		}
		return false;
	}
	
	/** 取得所有区论坛信息
	 * @return 区论坛
	 */
	public static List getAllClass(){
		
		try {
			return classdao.getAllClass();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getAllClass():\n" + e.toString());
		}
		return null;
	}
	
	/** 取得所有区论坛和子论坛信息
	 * @return 区论坛和子论坛
	 */
	public static List getAllClassF(){
		
		try {
			return classdao.getAllClassF();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getAllClassF():\n" + e.toString());
		}
		return null;
	}
	
	/** 取得区论坛的所有子论坛信息
	 * @return 所有子论坛
	 */
	public static List getOneClassFm(int classId){
		
		try {
			return classdao.getOneClassFm(classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getOneClassFm(int classId):\n" + e.toString());
		}
		return null;
	}
	
	/** 取得所有区论坛信息和他的所有子论坛信息(跳转连接用)
	 * @return 区论坛和子论坛
	 */
	public static List getJumpClassF(){
		
		try {
			return classdao.getJumpClassF();
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getJumpClassF():\n" + e.toString());
		}
		return null;
	}
	
	/** 取得某区论坛的所有子论坛信息
	 * @param classId 区论坛Id
	 * @return 区论坛所有子论坛
	 */
	public static BbsClass getAllFmByCId(int classId){
		
		try {
			return classdao.getAllFmByCId(classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getAllFmByCId(classId):\n" + e.toString());
		}
		return null;
	}
	
	// 后台大类操作
	
	/** 根据区论坛Id取得某区论坛
	 * @param classId 区论坛Id
	 * @return 某区论坛
	 */
	public static BbsClass getOneClass(int classId){
		
		try {
			return classdao.getClassById(classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getOneClass(int classId):\n" + e.toString());
		}
		return null;
	}
	/** 增加大类
	 * @param bbsclass 论坛大类
	 * @return true:增加成功 false:增加失败
	 */
	public static boolean addClass(BbsClass bbsclass){
		boolean flag = true;
		try {
			bbsclass.setId(classdao.getClassMaxId()+1);
			bbsclass.setClasssort(classdao.getMaxSortId()+1);
			classdao.addClass(bbsclass);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getAllFmByCId(classId):\n" + e.toString());
			flag = false;
		}
		return flag;
	}
	
	/** 更新大类
	 * @param bbsclass 论坛大类
	 * @return true:更新成功 false:更新失败
	 */
	public static boolean editClass(BbsClass bbsclass){
		boolean flag = true;
		try {
			flag = classdao.updateClass(bbsclass);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke editClass(BbsClass bbsclass):\n" + e.toString());
			flag = false;
		}
		return flag;
	}
	
	/** 删除大类
	 * @param id 论坛大类Id
	 * @return true:删除成功 false:删除失败
	 */
	public static boolean deleteClass(int id){
		boolean flag = true;
		try {
			flag = classdao.deleteClass(id);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke deleteClass(int id):\n" + e.toString());
			flag = false;
		}
		return flag;
	}
	
	/** 取得区论坛版主
	 * @param classId 区论坛Id
	 * @return 区论坛版主
	 */
	public static String getClassAdmin(int classId){
		
		try {
			return classdao.getClassAdmin(classId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getClassAdmin(int classId):\n" + e.toString());
		}
		return "";
	}
	
	/** 增加区版主,同时更新该用户类型(区版主:5)
	 * @param classId 区论坛Id
	 * @return true:成功 false:失败
	 */
	public static boolean addClassAdmin(int classId,String admin){
		boolean flag = true;
		try {
			flag = classdao.addAdmin(classId, admin);
			if(flag)
				flag = UserBiz.updateUserType(admin, 5);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke deleteClass(int id):\n" + e.toString());
			flag = false;
		}
		return flag;
	}
	/** 区论坛排序
	 * @param classId 区论坛Id
	 * @param classSort 区论坛顺序
	 * @return true:成功 false:失败
	 */
	public static boolean classSort(int classId,int classSort){
		boolean flag = true;
		try {
			flag = classdao.classSort(classId, classSort);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke classSort(int classId,int classSort):\n" + e.toString());
			flag = false;
		}
		return flag;
	}
}

⌨️ 快捷键说明

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