Skip to content
Snippets Groups Projects
Commit c36ad889 authored by 조대희's avatar 조대희
Browse files

feat: 내가 참여한 미팅 목록 조회 (#19)

parent 1ac37b1b
Branches
No related tags found
2 merge requests!31Develop,!26[#19] 통합 테스트 제작 및 서비스 로직 추가/수정
......@@ -341,6 +341,74 @@ class MeetingService {
};
}
async getMyMeetings(userId, pagination) {
const { limit = 20, offset = 0 } = pagination;
const meetings = await Meeting.findAll({
attributes: [
'id',
'title',
'description',
'time_idx_start',
'time_idx_end',
'location',
'time_idx_deadline',
'type',
'max_num',
'cur_num',
],
include: [
{
model: MeetingParticipant,
as: 'participants',
where: { user_id: userId },
attributes: [],
},
{
model: User,
as: 'creator',
attributes: ['name'],
}
],
where: {
[Op.or]: [
{ created_by: userId },
{ '$participants.user_id$': userId }
]
},
order: [['createdAt', 'DESC']],
offset
});
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 creatorName = meeting.creator ? meeting.creator.name : 'Unknown';
return new MeetingResponseDTO(meeting, !!isParticipant, hasConflict, creatorName);
})
);
return {
content,
hasNext
};
}
async closeMeeting(meetingId) {
const meeting = await Meeting.findByPk(meetingId);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment