Skip to content
Snippets Groups Projects
Commit ab1f0ec1 authored by Wo-ogie's avatar Wo-ogie
Browse files

feat: 약속 단건 조회, 상세 조회 API 응답 데이터에 현재 참가자 수(`currentParticipants`) 추가

parent e57c4558
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,6 @@ const {
createMeetingIsAlreadyClosedError,
createPasswordNotMatchedError,
createPasswordIsNullError,
createMostConfirmedTimeNotFoundError,
} = require('../errors/meetingErrors');
const MeetingResponse = require('../dto/response/meetingResponse');
const MeetingWithParticipantsResponse = require('../dto/response/meetingWithParticipantsResponse');
......@@ -71,6 +70,14 @@ async function getParticipantByNameAndMeetingId(name, meetingId) {
return participant;
}
async function getNumOfParticipantsByMeetingId(meetingId) {
return Participant.count({
where: {
MeetingId: meetingId,
},
});
}
async function validatePasswordIsMatched(requestPassword, exPassword) {
if (!requestPassword) {
throw createPasswordIsNullError();
......@@ -160,7 +167,13 @@ exports.entry = async (req, res, next) => {
exports.getMeetingById = async (req, res, next) => {
try {
const meeting = await getMeetingById(req.params.meetingId);
return res.json(MeetingResponse.from(meeting));
const currentParticipants = await getNumOfParticipantsByMeetingId(
meeting.id,
);
return res.json({
...MeetingResponse.from(meeting),
currentParticipants,
});
} catch (error) {
return next(error);
}
......@@ -171,7 +184,13 @@ exports.getMeetingDetailById = async (req, res, next) => {
const meeting = await getMeetingWithParticipantsAndSchedulesById(
req.params.meetingId,
);
return res.json(MeetingWithParticipantsResponse.from(meeting));
const currentParticipants = await getNumOfParticipantsByMeetingId(
meeting.id,
);
return res.json({
...MeetingWithParticipantsResponse.from(meeting),
currentParticipants,
});
} catch (error) {
return next(error);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment