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

📄 friendsbiz.java

📁 一个不错的bbs论坛系统.对初学者很有帮助
💻 JAVA
字号:
package com.yhbbs.user.biz;

import java.sql.SQLException;
import java.util.List;
import org.apache.log4j.Logger;
import com.yhbbs.user.dao.FriendsDaoIm;
import com.yhbbs.user.itface.bean.Friends;
import com.yhbbs.user.itface.dao.FriendsDao;

/**
 * <p>Title:论坛好友相关操作</p>
 * <li>论坛好友相关操作<br>
 * <br><b>WebSite: www.yyhweb.com</b>
 * <br><b>CopyRight: yyhweb[由由华网]</b>
 * @author stephen
 * @version YHBBS-2.0
 */
public class FriendsBiz {
	
	private static Logger bbslog = Logger.getLogger(FriendsBiz.class);
	
	private static FriendsDao frienddao = FriendsDaoIm.getInstance();
	
	/** 增加一个论坛好友
	 * @param friend 论坛好友
	 * @return 0:增加好友成功 1:他已经是我的好友
	 */
	public static int addFriends(Friends friend){
		int maxId = 0;
        try {
        	if(isFriends(friend)>0){
        		return 1;
        	}else{
	        	maxId = frienddao.getMaxId();
	        	friend.setId(maxId+1);
	            frienddao.addFriend(friend);
	            return 0;
        	}
        }
        catch(SQLException e) {
            bbslog.error("Throws a SqlException when invoke addFriends(friend):\n" + e.toString());
        }
        return 0;
	}
	
	/** 判断论坛好友是否存在
	 * @param friend 论坛好友(userId,fId)
	 * @return 论坛好友记录Id
	 */
	private static int isFriends(Friends friend){
		try {
			return frienddao.isFriends(friend);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke isFriend(friend):\n" + e.toString());
		}
		return 0;
	}
	
	/** 取得论坛用户好友列表
	 * @param userId 用户Id
	 * @return 论坛用户好友列表
	 */
	public static List getFriends(int userId){
		try {
			return frienddao.getFriends(userId);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke getFriends(int userId):\n" + e.toString());
		}
		return null;
	}
	
	/** 取得论坛用户好友列表
	 * @param friend 论坛好友
	 */
	public static void delFriend(Friends friend){
		try {
			frienddao.delFriend(friend);
		}
		catch(SQLException e) {
			bbslog.error("Throws a SqlException when invoke delFriend(friend):\n" + e.toString());
		}
		return ;
	}
	
}

⌨️ 快捷键说明

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