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-09-18 03:10:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6f4d55c956930807fceec43389c9492281428f5e
6f4d55c9
1 parent
677ab067
feat. 의사 자격 인증 : 번호입력 -> GCS 파일 업로드 / Batch로 약 정보 매달 1일 업데이트
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
22 deletions
server/index.js
server/package-lock.json
server/package.json
server/src/api/auth/auth.ctrl.js
server/src/api/auth/index.js
server/src/api/manage/manage.ctrl.js
server/src/util/Batch.js
server/yarn.lock
server/index.js
View file @
6f4d55c
...
...
@@ -6,7 +6,6 @@ const bodyparser = require('koa-bodyparser');
const
Mongoose
=
require
(
'mongoose'
);
const
api
=
require
(
'./src/api'
);
const
updateMedicineInfo
=
require
(
'./src/lib/UpdatingMedicineInfo'
);
const
MqttServer
=
require
(
'./src/util/MqttServer'
);
const
BatchSystem
=
require
(
'./src/util/Batch'
);
...
...
@@ -25,7 +24,7 @@ Mongoose.connect(MONGO_URL, {
useCreateIndex
:
true
}).
then
(()
=>
{
console
.
log
(
'\x1b[1;32mMongo DB is connected : '
,
MONGO_URL
,
'\x1b[0m'
);
// updateMedicineInfo.updateMedicineInfo
();
BatchSystem
.
updateMedicineData
();
}).
catch
(
e
=>
{
console
.
log
(
e
);
});
...
...
server/package-lock.json
View file @
6f4d55c
This diff is collapsed. Click to expand it.
server/package.json
View file @
6f4d55c
...
...
@@ -17,7 +17,9 @@
"author"
:
"박권수"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"@google-cloud/storage"
:
"^5.14.2"
,
"@koa/cors"
:
"^3.1.0"
,
"koa-body"
:
"^4.2.0"
,
"moment"
:
"^2.29.1"
,
"moment-timezone"
:
"^0.5.33"
,
"mqtt"
:
"^4.2.6"
,
...
...
server/src/api/auth/auth.ctrl.js
View file @
6f4d55c
...
...
@@ -7,6 +7,8 @@ const Joi = require('joi');
const
jwt
=
require
(
'jsonwebtoken'
);
const
axios
=
require
(
'axios'
);
const
{
Storage
}
=
require
(
'@google-cloud/storage'
);
const
GoogleStorageUrl
=
'https://storage.googleapis.com/'
;
exports
.
register
=
async
(
ctx
)
=>
{
const
{
...
...
@@ -95,17 +97,38 @@ exports.doctorRegister = async ctx => {
userId
,
password
,
passwordCheck
,
info
,
contact
,
hospitalNm
,
hospitalAddr
,
doctorType
,
doctorNm
,
}
=
ctx
.
request
.
body
;
const
{
doctorInfoFile
}
=
ctx
.
request
.
files
;
const
info
=
{
contact
,
hospitalAddr
,
hospitalNm
,
doctorType
,
doctorNm
,
doctorLicense
:
''
,
};
const
schema
=
Joi
.
object
().
keys
({
userId
:
Joi
.
string
().
email
().
max
(
50
).
required
(),
password
:
Joi
.
string
().
required
(),
passwordCheck
:
Joi
.
string
().
required
(),
info
:
Joi
.
object
().
required
(),
})
const
result
=
schema
.
validate
(
ctx
.
request
.
body
);
doctorInfoFile
:
Joi
.
object
().
required
(),
});
const
result
=
schema
.
validate
({
userId
,
password
,
passwordCheck
,
doctorInfoFile
,
});
if
(
result
.
error
||
password
!==
passwordCheck
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
...
...
@@ -145,19 +168,31 @@ exports.doctorRegister = async ctx => {
});
await
doctor
.
setPassword
(
password
);
doctor
.
save
();
const
doctorInfo
=
new
DoctorInfo
({
doctorId
:
userId
,
info
,
useYn
:
'W'
,
});
const
destination
=
userId
+
'_'
+
doctorInfoFile
.
name
;
const
storage
=
new
Storage
();
storage
.
bucket
(
'doctor-info'
).
upload
(
doctorInfoFile
.
path
,
{
destination
,
},
(
err
,
file
,
res
)
=>
{
if
(
err
)
console
.
log
(
'Fail to upload Doctor License'
);
else
{
info
.
doctorLicense
=
GoogleStorageUrl
+
`
${
res
.
bucket
}
/
${
res
.
name
}
`
;
console
.
log
(
'Success to Upload Doctor License!'
);
}
doctor
.
save
();
doctorInfo
.
save
();
const
doctorInfo
=
new
DoctorInfo
({
doctorId
:
userId
,
info
,
useYn
:
'W'
,
});
doctorInfo
.
save
();
});
ctx
.
status
=
201
;
}
exports
.
login
=
async
(
ctx
)
=>
{
...
...
server/src/api/auth/index.js
View file @
6f4d55c
const
Router
=
require
(
'koa-router'
)
const
KoaBody
=
require
(
'koa-body'
)({
multipart
:
true
});
const
authCtrl
=
require
(
'./auth.ctrl'
)
const
auth
=
new
Router
()
...
...
@@ -22,10 +23,10 @@ auth.get('/hospital', authCtrl.searchHospital);
/**
* 회원가입 (email type) : 의사 회원가입
* url : http://localhost:4000/api/auth/register/doctor
* request parameter : userId, password, passwordCheck, doctorInfo
* request parameter : userId, password, passwordCheck, doctorInfo
(File)
* return : null
*/
auth
.
post
(
'/register/doctor'
,
authCtrl
.
doctorRegister
)
auth
.
post
(
'/register/doctor'
,
KoaBody
,
authCtrl
.
doctorRegister
)
/**
* 로그인 (email type)
...
...
server/src/api/manage/manage.ctrl.js
View file @
6f4d55c
const
User
=
require
(
'../../models/user'
);
const
DoctorInfo
=
require
(
'../../models/doctorInfo'
);
const
Profile
=
require
(
'../../models/profile'
);
const
jwt
=
require
(
'jsonwebtoken'
);
const
{
Storage
}
=
require
(
'@google-cloud/storage'
);
/**
* 의사 회원가입을 요청한 회원 리스트를 확인한다.
* http methods : get
...
...
@@ -108,9 +110,25 @@ exports.getDoctorRegReqDetail = async ctx => {
return
;
}
const
fileName
=
doctorInfo
.
info
.
doctorLicense
.
split
(
'/'
).
pop
();
const
file
=
new
Storage
().
bucket
(
'doctor-info'
).
file
(
fileName
);
const
option
=
{
version
:
'v4'
,
expires
:
Date
.
now
()
+
1000
*
60
*
15
,
action
:
'read'
,
};
const
[
signedUrl
]
=
file
?
await
file
.
getSignedUrl
(
option
)
:
[
''
];
ctx
.
status
=
200
;
ctx
.
body
=
{
doctorInfo
,
doctorInfo
:
{
...
doctorInfo
.
_doc
,
info
:
{
...
doctorInfo
.
info
,
doctorLicense
:
signedUrl
,
},
},
};
}
catch
(
e
)
{
...
...
server/src/util/Batch.js
View file @
6f4d55c
...
...
@@ -13,6 +13,8 @@
const
Hub
=
require
(
'../models/hub'
);
const
Bottle
=
require
(
'../models/bottle'
);
const
BottleMedicine
=
require
(
'../models/bottleMedicine'
);
const
updateMedicineInfo
=
require
(
'../lib/UpdatingMedicineInfo'
);
// //매년 1월 1일 00시 00분에 1살씩 추가
...
...
@@ -28,9 +30,16 @@
// timezone : 'Asia/Tokyo',
// });
// };
//dosage에 따라, Push Notification을 발송한다.
//아침 8시, 점심 12시, 저녁 6시에 한번씩 발송
//매월 1일 0시 0분에 약 정보 업데이트
exports
.
updateMedicineData
=
async
()
=>
{
cron
.
schedule
(
'0 0 0 1 * *'
,
()
=>
{
updateMedicineInfo
.
updateMedicineInfo
();
});
};
//dosage에 따라, Push Notification을 발송한다.
//아침 8시, 점심 12시, 저녁 6시에 한번씩 발송
exports
.
PushNotifyByDosage
=
async
()
=>
{
//매일 아침 8시 : 복용량 상관 없이 보냄
...
...
server/yarn.lock
View file @
6f4d55c
This diff could not be displayed because it is too large.
Please
register
or
login
to post a comment