Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebBack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebBack
Commits
c0896712
Commit
c0896712
authored
4 months ago
by
조대희
Browse files
Options
Downloads
Patches
Plain Diff
feat: 미팅 탈퇴하기 (
#19
)
parent
c36ad889
Branches
Branches containing commit
No related tags found
2 merge requests
!31
Develop
,
!26
[#19] 통합 테스트 제작 및 서비스 로직 추가/수정
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/meetingService.js
+61
-16
61 additions, 16 deletions
services/meetingService.js
with
61 additions
and
16 deletions
services/meetingService.js
+
61
−
16
View file @
c0896712
...
...
@@ -407,22 +407,6 @@ class MeetingService {
};
}
async
closeMeeting
(
meetingId
)
{
const
meeting
=
await
Meeting
.
findByPk
(
meetingId
);
if
(
!
meeting
)
{
throw
new
Error
(
'
모임을 찾을 수 없습니다.
'
);
}
if
(
meeting
.
type
===
'
CLOSE
'
)
{
throw
new
Error
(
'
이미 마감된 모임입니다.
'
);
}
meeting
.
type
=
'
CLOSE
'
;
await
meeting
.
save
();
return
meeting
;
}
async
getMeetingDetail
(
meetingId
,
userId
)
{
const
meeting
=
await
Meeting
.
findByPk
(
meetingId
,
{
include
:
[
...
...
@@ -530,6 +514,67 @@ class MeetingService {
// 저장
chatRoom
.
save
();
}
async
leaveMeeting
(
meetingId
,
userId
)
{
const
meeting
=
await
Meeting
.
findByPk
(
meetingId
);
if
(
!
meeting
)
{
throw
new
Error
(
'
모임을 찾을 수 없습니다.
'
);
}
await
sequelize
.
transaction
(
async
(
transaction
)
=>
{
// 참가자 확인
const
participant
=
await
MeetingParticipant
.
findOne
({
where
:
{
meeting_id
:
meetingId
,
user_id
:
userId
},
transaction
});
if
(
!
participant
)
{
throw
new
Error
(
'
참가하지 않은 모임입니다.
'
);
}
// 생성자는 탈퇴할 수 없음
if
(
meeting
.
created_by
===
userId
)
{
throw
new
Error
(
'
모임 생성자는 탈퇴할 수 없습니다.
'
);
}
// 참가자 제거
await
MeetingParticipant
.
destroy
({
where
:
{
meeting_id
:
meetingId
,
user_id
:
userId
},
transaction
});
// 관련 스케줄 삭제
await
Schedule
.
destroy
({
where
:
{
user_id
:
userId
,
title
:
`번개 모임:
${
meeting
.
title
}
`
,
time_idx
:
{
[
Op
.
between
]:
[
meeting
.
time_idx_start
,
meeting
.
time_idx_end
]
}
},
transaction
});
// 채팅방에서 제거
const
chatRoom
=
await
ChatRooms
.
findOne
({
chatRoomId
:
meeting
.
chatRoomId
});
if
(
chatRoom
)
{
const
user
=
await
User
.
findByPk
(
userId
);
chatRoom
.
participants
=
chatRoom
.
participants
.
filter
(
p
=>
p
!==
user
.
name
);
await
chatRoom
.
save
();
}
// 현재 인원 수 감소
await
meeting
.
decrement
(
'
cur_num
'
,
{
by
:
1
,
transaction
});
});
}
}
module
.
exports
=
new
MeetingService
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment