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
fc0d45aa
Commit
fc0d45aa
authored
4 months ago
by
조대희
Browse files
Options
Downloads
Patches
Plain Diff
refactor: meeting pagination 추가 (
#19
)
parent
a0e5e827
Branches
Branches containing commit
No related tags found
2 merge requests
!31
Develop
,
!26
[#19] 통합 테스트 제작 및 서비스 로직 추가/수정
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/meetingController.js
+21
-6
21 additions, 6 deletions
controllers/meetingController.js
services/meetingService.js
+29
-17
29 additions, 17 deletions
services/meetingService.js
with
50 additions
and
23 deletions
controllers/meetingController.js
+
21
−
6
View file @
fc0d45aa
...
...
@@ -21,9 +21,9 @@ class MeetingController {
async
createMeeting
(
req
,
res
)
{
try
{
const
userId
=
req
.
user
.
id
;
const
meetingData
=
{
...
req
.
body
,
created_by
:
userId
const
meetingData
=
{
...
req
.
body
,
created_by
:
userId
};
const
createMeetingDTO
=
new
CreateMeetingRequestDTO
(
meetingData
);
createMeetingDTO
.
validate
();
...
...
@@ -43,8 +43,23 @@ class MeetingController {
async
getMeetings
(
req
,
res
)
{
try
{
const
userId
=
req
.
user
.
id
;
// 인증 미들웨어를 통해 설정된 사용자 ID
const
meetings
=
await
MeetingService
.
getMeetings
(
userId
);
res
.
status
(
200
).
json
(
meetings
);
const
page
=
parseInt
(
req
.
query
.
page
)
||
0
;
const
size
=
parseInt
(
req
.
query
.
size
)
||
20
;
const
meetings
=
await
MeetingService
.
getMeetings
(
userId
,
{
limit
:
size
,
offset
:
page
*
size
});
res
.
status
(
200
).
json
({
success
:
true
,
data
:
{
content
:
meetings
.
content
,
page
:
page
,
size
:
size
,
hasNext
:
meetings
.
hasNext
}
});
}
catch
(
err
)
{
console
.
error
(
'
모임 목록 조회 오류:
'
,
err
);
res
.
status
(
500
).
json
({
error
:
err
.
message
||
'
모임 목록 조회 실패
'
});
...
...
@@ -77,7 +92,7 @@ class MeetingController {
const
userId
=
req
.
user
.
id
;
// 인증 미들웨어를 통해 설정된 사용자 ID
await
MeetingService
.
joinMeeting
(
meetingId
,
userId
);
res
.
status
(
200
).
json
({
message
:
'
모임 및 채팅방 참가 완료
'
});
}
catch
(
err
)
{
console
.
error
(
'
모임 참가 오류:
'
,
err
);
...
...
This diff is collapsed.
Click to expand it.
services/meetingService.js
+
29
−
17
View file @
fc0d45aa
...
...
@@ -281,7 +281,9 @@ class MeetingService {
}
async
getMeetings
(
userId
)
{
async
getMeetings
(
userId
,
pagination
)
{
const
{
limit
=
20
,
offset
=
0
}
=
pagination
;
const
meetings
=
await
Meeting
.
findAll
({
attributes
:
[
'
id
'
,
...
...
@@ -307,26 +309,36 @@ class MeetingService {
as
:
'
creator
'
,
attributes
:
[
'
name
'
],
}
]
],
order
:
[[
'
createdAt
'
,
'
DESC
'
]],
offset
});
return
Promise
.
all
(
meetings
.
map
(
async
(
meeting
)
=>
{
const
isParticipant
=
await
MeetingParticipant
.
findOne
({
where
:
{
meeting_id
:
meeting
.
id
,
user_id
:
userId
}
});
const
hasNext
=
meetings
.
length
>
limit
;
const
content
=
await
Promise
.
all
(
meetings
.
slice
(
0
,
limit
).
map
(
async
(
meeting
)
=>
{
const
isParticipant
=
await
MeetingParticipant
.
findOne
({
where
:
{
meeting_id
:
meeting
.
id
,
user_id
:
userId
}
});
const
hasConflict
=
await
ScheduleService
.
checkScheduleOverlapByTime
(
userId
,
meeting
.
time_idx_start
,
meeting
.
time_idx_end
);
const
hasConflict
=
await
ScheduleService
.
checkScheduleOverlapByTime
(
userId
,
meeting
.
time_idx_start
,
meeting
.
time_idx_end
);
const
creatorName
=
meeting
.
creator
?
meeting
.
creator
.
name
:
'
Unknown
'
;
return
new
MeetingResponseDTO
(
meeting
,
!!
isParticipant
,
hasConflict
,
creatorName
);
})
);
const
creatorName
=
meeting
.
creator
?
meeting
.
creator
.
name
:
'
Unknown
'
;
return
new
MeetingResponseDTO
(
meeting
,
!!
isParticipant
,
hasConflict
,
creatorName
);
}));
return
{
content
,
hasNext
};
}
...
...
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