Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
meanspec-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
MeanSpec (SCE338 2024-2 Group 1)
meanspec-backend
Commits
a71d1779
Commit
a71d1779
authored
5 months ago
by
Lee WooChang
Browse files
Options
Downloads
Patches
Plain Diff
feat: pc 삭제 기능 추가
parent
68d87585
Branches
Branches containing commit
No related tags found
1 merge request
!22
pc 삭제 기능 추가
Pipeline
#10878
failed
5 months ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/repositories/myRepository.js
+12
-0
12 additions, 0 deletions
src/repositories/myRepository.js
src/routes/my.js
+25
-0
25 additions, 0 deletions
src/routes/my.js
src/services/myService.js
+30
-0
30 additions, 0 deletions
src/services/myService.js
with
67 additions
and
0 deletions
src/repositories/myRepository.js
+
12
−
0
View file @
a71d1779
...
@@ -81,6 +81,18 @@ const myRepository = {
...
@@ -81,6 +81,18 @@ const myRepository = {
const
{
rowCount
}
=
await
pool
.
query
(
query
,
values
);
const
{
rowCount
}
=
await
pool
.
query
(
query
,
values
);
return
rowCount
>
0
;
return
rowCount
>
0
;
},
},
async
deleteCombinationById
(
combinationId
)
{
const
query
=
`
UPDATE combinations
SET owner_id = NULL
WHERE id = $1
`
;
const
values
=
[
combinationId
];
const
{
rowCount
}
=
await
pool
.
query
(
query
,
values
);
return
rowCount
>
0
;
}
};
};
export
default
myRepository
;
export
default
myRepository
;
This diff is collapsed.
Click to expand it.
src/routes/my.js
+
25
−
0
View file @
a71d1779
...
@@ -21,6 +21,31 @@ myRouter.get(
...
@@ -21,6 +21,31 @@ myRouter.get(
})
})
);
);
myRouter
.
delete
(
'
/pc/:pcId
'
,
authMiddleware
,
wrapAsync
(
async
(
req
,
res
)
=>
{
const
{
pcId
}
=
req
.
params
;
const
userId
=
req
.
user
?.
userId
;
if
(
!
userId
)
{
throw
new
ReportableError
(
400
,
'
유효한 사용자 정보가 없습니다.
'
);
}
if
(
!
pcId
)
{
throw
new
ReportableError
(
400
,
'
PC ID가 필요합니다.
'
);
}
const
result
=
await
myService
.
deleteUserPC
(
userId
,
pcId
);
if
(
result
.
success
)
{
return
res
.
sendResponse
(
result
.
message
,
200
,
{});
}
else
{
throw
new
ReportableError
(
500
,
'
PC 삭제 중 문제가 발생했습니다.
'
);
}
})
);
myRouter
.
patch
(
myRouter
.
patch
(
'
/pc/:combinationId/name
'
,
'
/pc/:combinationId/name
'
,
authMiddleware
,
authMiddleware
,
...
...
This diff is collapsed.
Click to expand it.
src/services/myService.js
+
30
−
0
View file @
a71d1779
...
@@ -178,6 +178,36 @@ const myService = {
...
@@ -178,6 +178,36 @@ const myService = {
return
await
ShareRepository
.
createCombinationUuid
(
combinationId
);
return
await
ShareRepository
.
createCombinationUuid
(
combinationId
);
},
},
async
deleteUserPC
(
userId
,
pcId
)
{
if
(
!
userId
||
!
pcId
)
{
throw
new
ReportableError
(
400
,
'
유효한 사용자 ID 및 PC ID가 필요합니다.
'
);
}
const
userExists
=
await
myRepository
.
checkUserExists
(
userId
);
if
(
!
userExists
)
{
throw
new
ReportableError
(
404
,
'
사용자를 찾을 수 없습니다.
'
);
}
const
combination
=
await
myRepository
.
getCombinationById
(
pcId
);
if
(
!
combination
)
{
throw
new
ReportableError
(
404
,
'
해당 PC 조합을 찾을 수 없습니다.
'
);
}
if
(
combination
.
userId
!==
userId
)
{
throw
new
ReportableError
(
403
,
'
해당 PC 조합에 대한 권한이 없습니다.
'
);
}
const
deleted
=
await
myRepository
.
deleteCombinationById
(
pcId
);
if
(
!
deleted
)
{
throw
new
ReportableError
(
500
,
'
PC 조합 삭제 중 문제가 발생했습니다.
'
);
}
return
{
success
:
true
,
message
:
'
PC 조합이 성공적으로 삭제되었습니다.
'
,
};
},
};
};
export
default
myService
;
export
default
myService
;
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