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
309010e6
Commit
309010e6
authored
5 months ago
by
Lee WooChang
Browse files
Options
Downloads
Patches
Plain Diff
feat: pc 이름 변경기능 추가
parent
21ba0ab2
Branches
Branches containing commit
No related tags found
1 merge request
!14
PC 이름 변경기능 추가
Pipeline
#10787
passed
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
+18
-0
18 additions, 0 deletions
src/routes/my.js
src/services/myService.js
+39
-0
39 additions, 0 deletions
src/services/myService.js
with
69 additions
and
0 deletions
src/repositories/myRepository.js
+
12
−
0
View file @
309010e6
...
...
@@ -45,6 +45,18 @@ const myRepository = {
return
rows
.
length
>
0
?
rows
[
0
].
combination_id
:
null
;
},
async
updateCombinationName
(
combinationId
,
newName
)
{
const
query
=
`
UPDATE combinations
SET name = $1, updated_at = NOW()
WHERE id = $2
`
;
const
values
=
[
newName
,
combinationId
];
const
{
rowCount
}
=
await
pool
.
query
(
query
,
values
);
return
rowCount
>
0
;
},
};
export
default
myRepository
;
This diff is collapsed.
Click to expand it.
src/routes/my.js
+
18
−
0
View file @
309010e6
...
...
@@ -21,6 +21,24 @@ myRouter.get(
})
);
myRouter
.
patch
(
'
/pc/:combinationId/name
'
,
authMiddleware
,
wrapAsync
(
async
(
req
,
res
)
=>
{
const
{
pcId
}
=
req
.
params
;
const
{
newName
}
=
req
.
body
;
const
userId
=
req
.
user
.
id
;
if
(
!
newName
||
typeof
newName
!==
'
string
'
)
{
throw
new
ReportableError
(
400
,
'
유효한 새로운 이름이 필요합니다.
'
);
}
const
result
=
await
myService
.
updateCombinationName
(
userId
,
pcId
,
newName
);
return
res
.
status
(
200
).
json
(
result
);
})
);
myRouter
.
get
(
'
/registration-code
'
,
authMiddleware
,
...
...
This diff is collapsed.
Click to expand it.
src/services/myService.js
+
39
−
0
View file @
309010e6
...
...
@@ -124,6 +124,45 @@ const myService = {
return
pcs
;
},
async
updateCombinationName
(
userId
,
combinationId
,
newName
)
{
if
(
!
userId
||
!
combinationId
||
!
newName
)
{
throw
new
ReportableError
(
400
,
'
유효한 사용자 ID, 조합 ID, 및 새로운 이름이 필요합니다.
'
);
}
const
userExists
=
await
myRepository
.
checkUserExists
(
userId
);
if
(
!
userExists
)
{
throw
new
ReportableError
(
404
,
'
사용자를 찾을 수 없습니다.
'
);
}
const
combination
=
await
myRepository
.
getCombinationById
(
combinationId
);
if
(
!
combination
)
{
throw
new
ReportableError
(
404
,
'
조합을 찾을 수 없습니다.
'
);
}
if
(
combination
.
userId
!==
userId
)
{
throw
new
ReportableError
(
403
,
'
해당 조합에 대한 권한이 없습니다.
'
);
}
const
updated
=
await
myRepository
.
updateCombinationName
(
combinationId
,
newName
);
if
(
!
updated
)
{
throw
new
ReportableError
(
500
,
'
조합 이름을 업데이트하는 중 문제가 발생했습니다.
'
);
}
return
{
success
:
true
,
message
:
'
조합 이름이 성공적으로 변경되었습니다.
'
,
};
},
};
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