Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
When Meet - Backend
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
websystem2023-2
When Meet - Backend
Commits
f9fe2c5f
Commit
f9fe2c5f
authored
1 year ago
by
Wo-ogie
Browse files
Options
Downloads
Patches
Plain Diff
feat: id, 이름으로 참가자 단건 조회하기 API 구현
parent
a1666477
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/participant.js
+42
-0
42 additions, 0 deletions
controllers/participant.js
errors/participantErrors.js
+6
-0
6 additions, 0 deletions
errors/participantErrors.js
routes/participant.js
+6
-0
6 additions, 0 deletions
routes/participant.js
with
54 additions
and
0 deletions
controllers/participant.js
+
42
−
0
View file @
f9fe2c5f
...
...
@@ -2,6 +2,7 @@ const bcrypt = require('bcrypt');
const
{
createPasswordIsNullError
}
=
require
(
'
../errors/meetingErrors
'
);
const
{
createParticipantIsAlreadyExistError
,
createParticipantNotFoundError
,
}
=
require
(
'
../errors/participantErrors
'
);
const
ParticipantResponse
=
require
(
'
../dto/response/participantResponse
'
);
const
{
Participant
}
=
require
(
'
../models
'
);
...
...
@@ -17,6 +18,18 @@ async function createParticipant(name, password, email, meetingId) {
});
}
async
function
getParticipantById
(
participantId
)
{
const
participant
=
await
Participant
.
findOne
({
where
:
{
id
:
participantId
,
},
});
if
(
!
participant
)
{
throw
createParticipantNotFoundError
();
}
return
participant
;
}
async
function
findParticipantByMeetingIdAndName
(
meetingId
,
name
)
{
return
Participant
.
findOne
({
where
:
{
...
...
@@ -26,6 +39,14 @@ async function findParticipantByMeetingIdAndName(meetingId, name) {
});
}
async
function
getParticipantByMeetingIdAndName
(
meetingId
,
name
)
{
const
participant
=
await
findParticipantByMeetingIdAndName
(
meetingId
,
name
);
if
(
!
participant
)
{
throw
createParticipantNotFoundError
();
}
return
participant
;
}
async
function
encryptPassword
(
password
,
next
)
{
if
(
!
password
)
{
return
next
(
createPasswordIsNullError
());
...
...
@@ -69,6 +90,27 @@ exports.createParticipant = async (req, res, next) => {
}
};
exports
.
getParticipantById
=
async
(
req
,
res
,
next
)
=>
{
try
{
const
participant
=
await
getParticipantById
(
req
.
params
.
participantId
);
return
res
.
json
(
ParticipantResponse
.
from
(
participant
));
}
catch
(
error
)
{
return
next
(
error
);
}
};
exports
.
getParticipantByName
=
async
(
req
,
res
,
next
)
=>
{
try
{
const
participant
=
await
getParticipantByMeetingIdAndName
(
req
.
params
.
meetingId
,
req
.
query
.
name
,
);
return
res
.
json
(
ParticipantResponse
.
from
(
participant
));
}
catch
(
error
)
{
return
next
(
error
);
}
};
exports
.
getParticipantExistence
=
async
(
req
,
res
,
next
)
=>
{
try
{
const
participant
=
await
findParticipantByMeetingIdAndName
(
...
...
This diff is collapsed.
Click to expand it.
errors/participantErrors.js
+
6
−
0
View file @
f9fe2c5f
...
...
@@ -5,3 +5,9 @@ exports.createParticipantIsAlreadyExistError = () => {
error
.
status
=
409
;
return
error
;
};
exports
.
createParticipantNotFoundError
=
()
=>
{
const
error
=
new
Error
(
'
참가자 정보를 찾을 수 없습니다.
'
);
error
.
status
=
404
;
return
error
;
};
This diff is collapsed.
Click to expand it.
routes/participant.js
+
6
−
0
View file @
f9fe2c5f
const
express
=
require
(
'
express
'
);
const
{
createParticipant
,
getParticipantByName
,
getParticipantById
,
getParticipantExistence
,
}
=
require
(
'
../controllers/participant
'
);
...
...
@@ -8,6 +10,10 @@ const router = express.Router();
router
.
post
(
'
/:meetingId/participants
'
,
createParticipant
);
router
.
get
(
'
/:meetingId/participants
'
,
getParticipantByName
);
router
.
get
(
'
/:meetingId/participants/:participantId
'
,
getParticipantById
);
router
.
get
(
'
/:meetingId/participants/existence
'
,
getParticipantExistence
);
module
.
exports
=
router
;
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