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-08-17 23:11:12 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
926f5d91ea6e98c78e5774cd53c8d80e4ade2292
926f5d91
2 parents
35e4579c
c0d7c66d
Merge branch 'server' into web
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
design/요구사항명세서.xlsx
server/src/api/bottle/bottle.ctrl.js
server/src/api/bottle/index.js
server/src/models/bottleMedicine.js
design/요구사항명세서.xlsx
View file @
926f5d9
No preview for this file type
server/src/api/bottle/bottle.ctrl.js
View file @
926f5d9
...
...
@@ -337,7 +337,7 @@ exports.setMedicine = async(ctx) => {
// };
//로그인한 유저의 약병 리스트 가져오기
exports
.
getBottleList
=
async
(
ctx
)
=>
{
exports
.
get
Hubs
BottleList
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
...
...
@@ -373,4 +373,32 @@ exports.getBottleList = async(ctx) => {
ctx
.
status
=
200
;
ctx
.
body
=
bottleList
;
};
//현재 로그인한 유저의 모든 약병을 가져옴
exports
.
getAllBottleList
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
!
user
.
userTypeCd
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
const
hubList
=
await
Hub
.
find
({
userId
});
const
bottleList
=
[];
await
Promise
.
all
(
hubList
.
map
(
async
hub
=>
{
const
_bottleList
=
await
Bottle
.
find
({
hubId
:
hub
.
hubId
});
bottleList
.
push
(...
_bottleList
);
}));
ctx
.
status
=
200
;
ctx
.
body
=
bottleList
;
};
\ No newline at end of file
...
...
server/src/api/bottle/index.js
View file @
926f5d9
...
...
@@ -57,6 +57,15 @@ bottle.patch('/:bottleId', bottleCtrl.setMedicine);
* url : http://localhost:4000/api/bottle/hub/:hubId
* return : bottle List(json type List)
*/
bottle
.
get
(
'/hub/:hubId'
,
bottleCtrl
.
getBottleList
)
bottle
.
get
(
'/hub/:hubId'
,
bottleCtrl
.
getHubsBottleList
);
/**
* 현재 로그인한 유저의 모든 약병을 조회함
* request parameter : x
* url : http://localhost:4000/api/bottle/
* return : bottle List
*/
bottle
.
get
(
'/'
,
bottleCtrl
.
getAllBottleList
);
module
.
exports
=
bottle
;
\ No newline at end of file
...
...
server/src/models/bottleMedicine.js
View file @
926f5d9
...
...
@@ -27,7 +27,7 @@ const BottleMedicineSchema = new Schema({
type
:
Date
,
required
:
true
,
default
:
Date
.
now
,
}
}
,
});
BottleMedicineSchema
.
methods
.
setDoctorId
=
function
(
doctorId
)
{
...
...
Please
register
or
login
to post a comment