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
059ea81f
Commit
059ea81f
authored
4 months ago
by
조대희
Browse files
Options
Downloads
Patches
Plain Diff
feat: 사용자 존재 유효성 검사 (
#7
)
parent
aa60d98a
No related branches found
Branches containing commit
No related tags found
2 merge requests
!31
Develop
,
!8
[#7] Friend 서비스 로직 개발
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/friendService.js
+14
-1
14 additions, 1 deletion
services/friendService.js
with
14 additions
and
1 deletion
services/friendService.js
+
14
−
1
View file @
059ea81f
...
...
@@ -3,13 +3,26 @@ const Friend = require('../models/Friend');
const
User
=
require
(
'
../models/user
'
);
class
friendService
{
/**
* User 존재 여부 유효성 검사
*/
async
validUser
(
userId
)
{
const
user
=
await
User
.
findByPk
(
userId
);
if
(
!
user
)
{
throw
new
Error
(
'
User not found
'
);
}
return
user
;
}
/**
* 친구 요청 보내기
* 나 자신에게 보내기 or 이미 존재하는 친구 -> X
* 이후, PENDING 상태로 변환 -> 수락/거절에 따라 변화
*/
async
sendFriendRequest
(
userId
,
friendId
)
{
await
this
.
validUser
(
userId
);
await
this
.
validUser
(
friendId
);
if
(
userId
===
friendId
)
{
throw
new
Error
(
'
Cannot send friend request to yourself
'
);
}
...
...
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