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 19:47:43 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
382e1eb2dad25a7300601386bd438eb220f09d50
382e1eb2
2 parents
3d3ed3eb
13e31fb5
Merge branch 'server' into web
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
3 deletions
server/src/api/user/index.js
server/src/api/user/user.ctrl.js
server/src/models/doctorInfo.js
server/src/api/user/index.js
View file @
382e1eb
...
...
@@ -12,12 +12,20 @@ const user = new Router();
user
.
get
(
'/'
,
userCtrl
.
getMyDetail
);
/**
* 현재 로그인한 유저에 등록된 의사 목록 가져옴
* request parameter : token
* url : http://localhost:4000/api/user/doctor
* return : Doctor List
*/
user
.
get
(
'/doctor'
,
userCtrl
.
getMyDoctorList
);
/**
* 유저를 등록하려는 의사의 요청을 전부 보여준다
* request parameter : token,
* url : http://localhost:4000/api/user/doctorrequest
* return : List
*/
user
.
get
(
'/doctorrequest'
,
userCtrl
.
viewAllDoctorRegister
);
user
.
get
(
'/doctorrequest'
,
userCtrl
.
viewAllDoctorRegister
Req
);
/**
...
...
@@ -30,3 +38,4 @@ user.post('/doctorrequest', userCtrl.acceptDoctorRegister);
module
.
exports
=
user
;
...
...
server/src/api/user/user.ctrl.js
View file @
382e1eb
...
...
@@ -2,6 +2,7 @@
const
User
=
require
(
'../../models/user'
);
const
Profile
=
require
(
'../../models/profile'
);
const
PatientInfo
=
require
(
'../../models/patientInfo'
);
const
DoctorInfo
=
require
(
'../../models/doctorInfo'
);
const
jwt
=
require
(
'jsonwebtoken'
);
...
...
@@ -41,11 +42,50 @@ exports.updateMyInfo = async ctx => {
};
/**
* 현재 로그인한 유저(환자)를 관리하는 의사 목록을 가져온다.
* http methods : get
* @param {*} ctx
* @returns
*/
exports
.
getMyDoctorList
=
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
!==
'NORMAL'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
const
patientInfoList
=
await
PatientInfo
.
find
({
patientId
:
userId
,
useYn
:
'Y'
,
});
const
doctorList
=
await
Promise
.
all
(
patientInfoList
.
map
(
async
patientInfo
=>
{
const
doctorInfo
=
await
DoctorInfo
.
findOne
({
doctorId
:
patientInfo
.
doctorId
,
useYn
:
'Y'
,
});
return
doctorInfo
.
info
;
}));
ctx
.
status
=
200
;
ctx
.
body
=
doctorList
;
};
/**
* 의사가 요청한 환자 등록을 확인한다.
* @param {*} ctx
* http methods : get
*/
exports
.
viewAllDoctorRegister
=
async
ctx
=>
{
exports
.
viewAllDoctorRegister
Req
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
...
...
@@ -99,3 +139,4 @@ exports.acceptDoctorRegister = async ctx => {
ctx
.
status
=
200
;
};
...
...
server/src/models/doctorInfo.js
View file @
382e1eb
...
...
@@ -9,6 +9,8 @@ const DoctorInfoSchema = new Schema({
hospitalNm
:
{
type
:
String
,
default
:
null
,
},
hospitalAddr
:
{
type
:
String
,
default
:
null
,
},
contact
:
{
type
:
String
,
required
:
true
,
},
doctorType
:
{
type
:
String
,
default
:
null
,
},
doctorNm
:
{
type
:
String
,
required
:
true
,
},
},
useYn
:
{
type
:
String
,
default
:
'W'
,
required
:
true
,
},
});
...
...
@@ -22,4 +24,4 @@ DoctorInfoSchema.methods.setUseYn = function(useYn) {
};
module
.
exports
=
mongoose
.
model
(
'DoctorInfo'
,
DoctorInfoSchema
);
\ No newline at end of file
module
.
exports
=
mongoose
.
model
(
'DoctorInfo'
,
DoctorInfoSchema
);
...
...
Please
register
or
login
to post a comment