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-19 10:26:24 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
ba01e00636ef9c898d55dda42fd4a9695ff55ea9
ba01e006
2 parents
c05ce4cf
5ecdd058
Merge branch 'server' into web
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
4 deletions
server/src/api/auth/auth.ctrl.js
server/src/api/doctor/doctor.ctrl.js
server/src/api/doctor/index.js
server/src/api/auth/auth.ctrl.js
View file @
ba01e00
/* eslint-disable no-undef */
//회원가입, 로그인 및 로그아웃에 관한 api
const
User
=
require
(
'../../models/user'
);
const
Profile
=
require
(
'../../models/profile'
);
...
...
@@ -175,8 +176,8 @@ exports.verifyToken = async(ctx) => {
return
;
}
await
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
,
(
err
,
decoded
)
=>
{
if
(
err
)
{
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
,
(
err
,
decoded
)
=>
{
if
(
err
)
{
ctx
.
status
=
400
;
ctx
.
body
=
err
;
return
;
...
...
server/src/api/doctor/doctor.ctrl.js
View file @
ba01e00
...
...
@@ -127,10 +127,29 @@ exports.getPatientDetail = async ctx => {
reqUserBottleList
.
push
(...
bottleList
);
}));
const
reqUserBmList
=
[];
await
Promise
.
all
(
reqUserBottleList
.
map
(
async
bottle
=>
{
const
bmList
=
await
BottleMedicine
.
find
({
doctorId
:
userId
,
bottleId
:
bottle
.
bottleId
,
}).
sort
({
regDtm
:
'desc '
}).
limit
(
1
);
reqUserBmList
.
push
(...
bmList
);
}));
const
bottleList
=
await
Promise
.
all
(
reqUserBmList
.
map
(
async
bottleMedicine
=>
{
const
{
dosage
,
regDtm
,
medicineId
}
=
bottleMedicine
;
const
medicine
=
await
Medicine
.
findOne
({
medicineId
});
return
{
dosage
,
regDtm
,
medicine
,
};
}));
const
result
=
{
profile
,
info
:
isDoctorsPatient
.
getInfo
(),
bottleList
:
reqUserBottleList
,
bottleList
,
};
ctx
.
status
=
200
;
...
...
@@ -296,6 +315,37 @@ exports.writeReqBottleFeedback = async ctx => {
};
exports
.
searchPatientById
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
// eslint-disable-next-line no-undef
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
user
.
userTypeCd
!==
'DOCTOR'
)
{
ctx
.
status
=
403
;
return
;
}
const
{
patientId
}
=
ctx
.
params
;
const
patient
=
await
User
.
findByUserId
(
patientId
);
if
(
!
patient
||
patient
.
useYn
!==
'Y'
)
{
ctx
.
status
=
404
;
return
;
}
const
patientProfile
=
await
Profile
.
findOne
({
userId
:
patientId
});
ctx
.
status
=
200
;
ctx
.
body
=
{
patientNm
:
patientProfile
.
userNm
,
patientId
,
};
};
/**
* 새로운 환자를 등록한다.
* @param {*} ctx
...
...
server/src/api/doctor/index.js
View file @
ba01e00
...
...
@@ -53,9 +53,18 @@ doctor.patch('/patient', doctorCtrl.writeReqPatientReport);
*/
doctor
.
post
(
'/bottle'
,
doctorCtrl
.
writeReqBottleFeedback
);
/**
* 현재 로그인한 유저(의사)가 이메일로 유저를 검색함
* request parameter : patientId
* url : http://localhost:4000/api/doctor/patient/search/:patientId
* return : patient Info(simple)
*/
doctor
.
get
(
'/patient/search/:patientId'
,
doctorCtrl
.
searchPatientById
);
/**
* 현재 로그인한 유저(의사)의 관리 환자를 등록함.
* request parameter :
reqUser
Id
* request parameter :
patient
Id
* url : http://localhost:4000/doctor/patient
* return : null
*/
...
...
Please
register
or
login
to post a comment