Skip to content
Snippets Groups Projects

[#7] Friend 서비스 로직 개발

Merged 조대희 requested to merge feature/#7 into develop
1 file
+ 6
6
Compare changes
  • Side-by-side
  • Inline
+ 6
6
@@ -37,7 +37,7 @@ class friendService {
@@ -37,7 +37,7 @@ class friendService {
/**
/**
* 받은 친구 요청 목록 조회
* 받은 친구 요청 목록 조회
*/
*/
async getReveivedRequests(userId) {
async getReceivedRequests(userId) {
return Friend.findAll({
return Friend.findAll({
where: {
where: {
friend_id: userId,
friend_id: userId,
@@ -57,7 +57,7 @@ class friendService {
@@ -57,7 +57,7 @@ class friendService {
async getSentRequests(userId) {
async getSentRequests(userId) {
return Friend.findAll({
return Friend.findAll({
where: {
where: {
user_Id: userId,
user_id: userId,
status: 'PENDING'
status: 'PENDING'
},
},
include: [{
include: [{
@@ -81,10 +81,10 @@ class friendService {
@@ -81,10 +81,10 @@ class friendService {
});
});
if (!request) {
if (!request) {
throw new Error('Friend reqeust not found');
throw new Error('Friend request not found');
}
}
return request.update({ status: 'ACCEPTED '});
return request.update({ status: 'ACCEPTED'});
}
}
/**
/**
@@ -124,7 +124,7 @@ class friendService {
@@ -124,7 +124,7 @@ class friendService {
attributes: ['id', 'name', 'email']
attributes: ['id', 'name', 'email']
}, {
}, {
model: User,
model: User,
as: 'friend',
as: 'user',
attributes: ['id', 'name', 'email']
attributes: ['id', 'name', 'email']
}]
}]
});
});
@@ -133,7 +133,7 @@ class friendService {
@@ -133,7 +133,7 @@ class friendService {
/**
/**
* 친구 삭제
* 친구 삭제
*/
*/
async deleteFriend(userId, freindId) {
async deleteFriend(userId, friendId) {
const result = await Friend.destroy({
const result = await Friend.destroy({
where: {
where: {
[Op.or]: [
[Op.or]: [
Loading