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-18 22:36:32 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8e07943e8fd41c6b029ffca544141de57c0bacd0
8e07943e
2 parents
382e1eb2
96da687e
Merge branch 'server' into web
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
0 deletions
server/src/api/doctor/doctor.ctrl.js
server/src/api/doctor/index.js
server/src/api/user/user.ctrl.js
server/src/api/doctor/doctor.ctrl.js
View file @
8e07943
...
...
@@ -8,8 +8,49 @@ const TakeMedicineHist = require('../../models/takeMedicineHistory');
const
Feedback
=
require
(
'../../models/feedback'
);
const
Hub
=
require
(
'../../models/hub'
);
const
PatientInfo
=
require
(
'../../models/patientInfo'
);
const
DoctorInfo
=
require
(
'../../models/doctorInfo'
);
const
jwt
=
require
(
'jsonwebtoken'
);
/**
* 현재 로그인한 유저의 의사 정보를 가져온다
* http methods : get
* @param {*} ctx
* @returns
*/
exports
.
getDoctorsInfo
=
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'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
const
doctorInfo
=
await
DoctorInfo
.
findOne
({
doctorId
:
userId
,
useYn
:
'Y'
});
if
(
!
doctorInfo
)
{
ctx
.
status
=
401
;
ctx
.
body
=
{
error
:
'인증되지 않은 회원'
}
return
;
}
ctx
.
status
=
200
;
ctx
.
body
=
doctorInfo
.
info
;
};
/**
* 관리하는 환자 목록을 모두 가져옴
* @param {*} ctx
...
...
server/src/api/doctor/index.js
View file @
8e07943
...
...
@@ -3,6 +3,15 @@ const doctorCtrl = require('./doctor.ctrl');
const
doctor
=
new
Router
();
/**
* 현재 로그인한 유저(의사)의 정보를 가져옴.
* request parameter : token
* url : http://localhost:4000/doctor/
* return : doctor's Info
*/
doctor
.
get
(
'/'
,
doctorCtrl
.
getDoctorsInfo
);
/**
* 현재 로그인한 유저(의사)의 관리 환자 목록을 가져옴
* request parameter
...
...
server/src/api/user/user.ctrl.js
View file @
8e07943
...
...
@@ -18,6 +18,7 @@ exports.getMyDetail = async ctx => {
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
||
user
.
useYn
!==
'Y'
)
{
...
...
@@ -54,6 +55,7 @@ exports.getMyDoctorList = async ctx => {
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
!==
'NORMAL'
||
user
.
useYn
!==
'Y'
)
{
...
...
@@ -92,6 +94,7 @@ exports.viewAllDoctorRegisterReq = async ctx => {
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
||
user
.
userTypeCd
!==
'NORMAL'
||
user
.
useYn
!==
'Y'
)
{
...
...
@@ -118,6 +121,7 @@ exports.acceptDoctorRegister = async ctx => {
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
||
user
.
userTypeCd
!==
'NORMAL'
||
user
.
useYn
!==
'Y'
)
{
...
...
Please
register
or
login
to post a comment