박권수

feat. profile userAge -> birth

......@@ -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
......
......@@ -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,
});
......
......@@ -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;
};
......
......@@ -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시에 한번씩 발송
......