Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-05-17 15:30:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
84c4f31cc682eeb8d3183f0f03df24410fc5ceff
84c4f31c
1 parent
b780564f
feat. get user's bottle List
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
server/src/api/bottle/bottle.ctrl.js
server/src/api/bottle/index.js
server/src/api/bottle/bottle.ctrl.js
View file @
84c4f31
...
...
@@ -162,3 +162,40 @@ exports.setMedicine = async(ctx) => {
ctx
.
status
=
200
;
}
//로그인한 유저의 약병 리스트 가져오기
exports
.
getBottleList
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
);
if
(
!
token
)
{
ctx
.
status
=
401
;
return
;
}
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
hubList
=
await
Hub
.
find
({
userId
})
if
(
!
hubList
)
{
ctx
.
status
=
404
;
return
;
}
const
bottleList
=
await
getBottleListByHub
(
hubList
);
if
(
!
bottleList
)
{
ctx
.
status
=
404
;
return
;
}
ctx
.
status
=
200
;
ctx
.
body
=
bottleList
;
}
const
getBottleListByHub
=
async
(
hubList
)
=>
{
const
result
=
[]
for
(
const
hub
of
hubList
)
{
const
bottle
=
await
Bottle
.
find
({
hubId
:
hub
.
hubId
});
result
.
push
(...
bottle
)
}
return
result
;
}
...
...
server/src/api/bottle/index.js
View file @
84c4f31
...
...
@@ -35,4 +35,12 @@ bottle.get('/:bottleId', bottleCtrl.lookupInfo);
*/
bottle
.
patch
(
'/:bottleId'
,
bottleCtrl
.
setMedicine
);
/**
* 현재 로그인한 유저의 약병 리스트를 가져옴
* request parameter : x
* url : http://localhost:4000/api/bottle
* return : bottle List(json type List)
*/
bottle
.
get
(
'/'
,
bottleCtrl
.
getBottleList
)
module
.
exports
=
bottle
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment