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-15 19:40:59 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
ebee453057e4d6ffa08963df9ceeb11f428405d3
ebee4530
2 parents
21ae8f80
e7db2951
Merge branch 'server' into web
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
23 deletions
server/index.js
server/src/api/auth/auth.ctrl.js
server/src/models/profile.js
server/src/util/Batch.js
server/index.js
View file @
ebee453
...
...
@@ -38,6 +38,5 @@ app.use(router.routes()).use(router.allowedMethods());
app
.
listen
(
SERVER_PORT
,
()
=>
{
console
.
log
(
'\x1b[1;36mPORT : '
,
SERVER_PORT
,
'is connected\x1b[0m'
);
MqttServer
.
on
();
BatchSystem
.
CheckNewYear
();
BatchSystem
.
PushNotifyByDosage
();
});
\ No newline at end of file
...
...
server/src/api/auth/auth.ctrl.js
View file @
ebee453
...
...
@@ -13,7 +13,7 @@ exports.register = async(ctx) => {
password
,
passwordCheck
,
userNm
,
userAge
,
birth
,
contact
,
}
=
ctx
.
request
.
body
;
...
...
@@ -22,7 +22,7 @@ exports.register = async(ctx) => {
password
:
Joi
.
string
().
required
(),
passwordCheck
:
Joi
.
string
().
required
(),
userNm
:
Joi
.
string
().
required
(),
userAge
:
Joi
.
number
().
required
(),
birth
:
Joi
.
string
().
required
(),
contact
:
Joi
.
string
().
required
(),
});
...
...
@@ -55,7 +55,7 @@ exports.register = async(ctx) => {
const
profile
=
new
Profile
({
userId
,
userNm
,
userAge
,
birth
,
contact
,
});
...
...
server/src/models/profile.js
View file @
ebee453
...
...
@@ -5,7 +5,7 @@ const Schema = mongoose.Schema;
const
ProfileSchema
=
new
Schema
({
userId
:
{
type
:
String
,
required
:
true
,
ref
:
'User'
,
},
userNm
:
{
type
:
String
,
required
:
true
,
},
userAge
:
{
type
:
Number
,
required
:
true
,
},
birth
:
{
type
:
String
,
required
:
true
,
},
contact
:
{
type
:
String
,
required
:
true
,
},
deviceToken
:
{
type
:
String
,
default
:
null
,
},
});
...
...
@@ -18,10 +18,6 @@ ProfileSchema.methods.updateUserContact = function(contact) {
this
.
contact
=
contact
;
};
ProfileSchema
.
methods
.
updateUserAge
=
function
()
{
this
.
userAge
=
this
.
userAge
+
1
;
};
ProfileSchema
.
methods
.
updateDeviceToken
=
function
(
deviceToken
)
{
this
.
deviceToken
=
deviceToken
;
};
...
...
server/src/util/Batch.js
View file @
ebee453
...
...
@@ -3,8 +3,7 @@
* 21/09/14
* Author : 박권수
* 배치 시스템
* 1) 매년 지나면 프로필의 Age를 +1
* 2) Dosage에 따라, Push Notification 발송
* 1) Dosage에 따라, Push Notification 발송
*/
const
cron
=
require
(
'node-cron'
);
...
...
@@ -16,19 +15,19 @@
const
BottleMedicine
=
require
(
'../models/bottleMedicine'
);
//매년 1월 1일 00시 00분에 1살씩 추가
exports
.
CheckNewYear
=
()
=>
{
cron
.
schedule
(
'0 0 0 1 1 *'
,
async
()
=>
{
const
profileList
=
await
Profile
.
find
();
profileList
.
forEach
(
async
profile
=>
{
await
profile
.
updateUserAge
();
profile
.
save
();
});
//
//매년 1월 1일 00시 00분에 1살씩 추가
//
exports.CheckNewYear = () => {
//
cron.schedule('0 0 0 1 1 *', async () => {
//
const profileList = await Profile.find();
//
profileList.forEach(async profile => {
//
await profile.updateUserAge();
//
profile.save();
//
});
},
{
timezone
:
'Asia/Tokyo'
,
});
};
//
}, {
//
timezone : 'Asia/Tokyo',
//
});
//
};
//dosage에 따라, Push Notification을 발송한다.
//아침 8시, 점심 12시, 저녁 6시에 한번씩 발송
...
...
Please
register
or
login
to post a comment