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

refactor: 미팅 목록/상세 정보 조회 수정 (#19)

parent bef30033
Branches
No related tags found
No related merge requests found
...@@ -299,21 +299,34 @@ class MeetingService { ...@@ -299,21 +299,34 @@ class MeetingService {
{ {
model: MeetingParticipant, model: MeetingParticipant,
as: 'participants', as: 'participants',
where: { user_id: userId }, // userId와 매핑된 미팅만 가져옴 required: false,
attributes: [], attributes: [],
}, },
{ {
model: User, model: User,
as: 'creator', as: 'creator',
attributes: ['name'], // 미팅 생성자의 이름만 필요 attributes: ['name'],
}, }
], ]
}); });
return meetings.map((meeting) => { return Promise.all(meetings.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'; const creatorName = meeting.creator ? meeting.creator.name : 'Unknown';
return new MeetingResponseDTO(meeting, true, false, creatorName); return new MeetingResponseDTO(meeting, !!isParticipant, hasConflict, creatorName);
}); }));
} }
...@@ -451,7 +464,7 @@ class MeetingService { ...@@ -451,7 +464,7 @@ class MeetingService {
async getMeetingDetail(meetingId) { async getMeetingDetail(meetingId, userId) {
const meeting = await Meeting.findByPk(meetingId, { const meeting = await Meeting.findByPk(meetingId, {
include: [ include: [
{ {
...@@ -465,19 +478,25 @@ class MeetingService { ...@@ -465,19 +478,25 @@ class MeetingService {
include: [ include: [
{ {
model: User, model: User,
as: "user", // 'participantUser'에서 'user'로 수정 as: "user",
attributes: ["name", "email"], attributes: ["name", "email"],
}, }
], ]
}, }
], ]
}); });
if (!meeting) { if (!meeting) {
throw new Error("모임을 찾을 수 없습니다."); throw new Error("모임을 찾을 수 없습니다.");
} }
return new MeetingDetailResponseDTO(meeting); const hasConflict = await ScheduleService.checkScheduleOverlapByTime(
userId,
meeting.time_idx_start,
meeting.time_idx_end
);
return new MeetingDetailResponseDTO(meeting, hasConflict);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment