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
a2f2607a
Commit
a2f2607a
authored
4 months ago
by
tpgus2603
Browse files
Options
Downloads
Patches
Plain Diff
feature 변경사항 기록(
#15
)
parent
82f600bc
No related branches found
Branches containing commit
No related tags found
2 merge requests
!31
Develop
,
!27
[#15] invitecontroller 로직
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/inviteController.js
+67
-0
67 additions, 0 deletions
controllers/inviteController.js
controllers/meetingController.js
+1
-0
1 addition, 0 deletions
controllers/meetingController.js
with
68 additions
and
0 deletions
controllers/inviteController.js
+
67
−
0
View file @
a2f2607a
// controllers/inviteController.js
const
{
Invite
,
Meeting
,
User
,
MeetingParticipant
}
=
require
(
'
../models
'
);
const
MeetingService
=
require
(
'
../services/meetingService
'
);
/**
* 초대에 응답하는 메서드
* @param {number} inviteId - 응답할 초대의 ID
* @param {number} userId - 응답하는 사용자의 ID
* @param {string} response - 응답 (ACCEPTED, DECLINED)
* @returns {Object} 응답 결과
*/
async
function
respondToInvite
(
inviteId
,
userId
,
response
)
{
// 초대 조회
const
invite
=
await
Invite
.
findOne
({
where
:
{
id
:
inviteId
,
invitee_id
:
userId
,
},
include
:
[
{
model
:
Meeting
,
as
:
'
meeting
'
},
{
model
:
User
,
as
:
'
inviter
'
}
]
});
if
(
!
invite
)
{
throw
new
Error
(
'
초대를 찾을 수 없습니다.
'
);
}
if
(
!
[
'
ACCEPTED
'
,
'
DECLINED
'
].
includes
(
response
))
{
throw
new
Error
(
'
유효하지 않은 응답입니다.
'
);
}
if
(
response
===
'
ACCEPTED
'
)
{
// 초대 수락 시, MeetingService의 joinMeeting 메서드 호출
await
MeetingService
.
joinMeeting
(
invite
.
meeting_id
,
userId
);
}
// 초대를 삭제
await
invite
.
destroy
();
return
{
inviteId
,
response
};
}
/**
* 사용자가 받은 초대 목록을 조회하는 메서드
* @param {number} userId - 초대를 받은 사용자의 ID
* @returns {Array} 초대 목록
*/
async
function
getReceivedInvites
(
userId
)
{
const
invites
=
await
Invite
.
findAll
({
where
:
{
invitee_id
:
userId
,
status
:
'
PENDING
'
,
},
include
:
[
{
model
:
Meeting
,
as
:
'
meeting
'
},
{
model
:
User
,
as
:
'
inviter
'
,
attributes
:
[
'
id
'
,
'
name
'
,
'
email
'
]
},
],
});
return
invites
;
}
module
.
exports
=
{
respondToInvite
,
getReceivedInvites
,
};
This diff is collapsed.
Click to expand it.
controllers/meetingController.js
+
1
−
0
View file @
a2f2607a
...
...
@@ -16,6 +16,7 @@ class MeetingController {
* "location": "회의실 A",
* "deadline": "2024-04-25T23:59:59Z",
* "type": "OPEN" // "OPEN" 또는 "CLOSE"
* "max_num":
* }
*/
async
createMeeting
(
req
,
res
)
{
...
...
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