68 lines
2.0 KiB
JavaScript
68 lines
2.0 KiB
JavaScript
// friendService.js
|
|
const friendDao = require('../dao/friendDao');
|
|
const userDao = require("../dao/userDao");
|
|
|
|
class FriendService {
|
|
async sendFriendRequest(uid, fid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
const friendIdx = await userDao.getUserIdx(fid);
|
|
await friendDao.sendFriendRequest(myIdx, friendIdx);
|
|
}
|
|
|
|
async acceptFriendRequest(uid, fid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
const friendIdx = await userDao.getUserIdx(fid);
|
|
await friendDao.acceptFriendRequest(myIdx, friendIdx);
|
|
}
|
|
|
|
async addFriend(uid, fid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
const friendIdx = await userDao.getUserIdx(fid);
|
|
await friendDao.addFriend(myIdx, friendIdx);
|
|
}
|
|
|
|
async deleteFriend(uid, fid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
const friendIdx = await userDao.getUserIdx(fid);
|
|
await friendDao.deleteFriend(myIdx, friendIdx);
|
|
}
|
|
|
|
async getFriendList(uid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
return await friendDao.getAcceptedFriends(myIdx);
|
|
}
|
|
|
|
async addToBlackList(uid, bid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
const backIdx = await userDao.getUserIdx(bid);
|
|
await friendDao.addToBlackList(myIdx, backIdx);
|
|
}
|
|
|
|
async removeFromBlackList(uid, bid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
const backIdx = await userDao.getUserIdx(bid);
|
|
await friendDao.removeFromBlackList(myIdx, backIdx);
|
|
}
|
|
|
|
async getBlackList(uid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
return await friendDao.getBlackList(myIdx);
|
|
}
|
|
|
|
async getPendingFriendRequests(uid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
return await friendDao.getPendingFriendRequests(myIdx);
|
|
}
|
|
|
|
async getPendingFriendInvitations(uid) {
|
|
const myIdx = await userDao.getUserIdx(uid);
|
|
return await friendDao.getInviteFriendRequests(myIdx);
|
|
}
|
|
|
|
async findUser(name, uid) {
|
|
const users = await userDao.findUser(name, uid);
|
|
return users;
|
|
}
|
|
}
|
|
|
|
module.exports = new FriendService(); |