박권수

feat. 사용성 개선 및 db 수정

......@@ -103,6 +103,7 @@ exports.bottleDisconnect = async(ctx) => {
const topic = 'bottle/' + bottleId + '/bts';
Mqtt.mqttUnsubscribe(client, topic);
await BottleMedicine.updateMany({ bottleId }, { useYn : 'N' });
await Bottle.deleteOne({ bottleId });
ctx.status = 204;
......
......@@ -358,6 +358,7 @@ exports.writeReqBottleFeedback = async ctx => {
ctx.status = 200;
};
/**
......@@ -451,6 +452,15 @@ exports.registerNewPatient = async ctx => {
await patientInfo.updateInfo('환자 등록 요청');
await patientInfo.save();
const profile = await Profile.findByUserId(patientId);
const { deviceToken } = profile;
sendPushMessage({
deviceToken,
title : '새로운 의사 등록 요청이 왔습니다.',
body : '어플리케이션을 실행해 확인하세요.',
});
ctx.status = 200;
};
......
......@@ -5,6 +5,7 @@ const User = require('../../models/user');
const Mqtt = require('../../util/MqttModule');
const DataProcess = require('../../util/DataProcess');
const jwt = require('jsonwebtoken');
const BottleMedicine = require('../../models/bottleMedicine');
//허브 연결
exports.hubConnect = async (ctx) => {
......@@ -81,6 +82,11 @@ exports.hubDisconnect = async(ctx) => {
const hosting = await hub.getHubHost();
Mqtt.mqttOff(hosting);
const bottleList = await Bottle.find({ hubId });
await Promise.all(bottleList.map(async bottle => {
await BottleMedicine.updateMany({ bottleId : bottle.bottleId }, { useYn : 'N' });
}));
await Bottle.deleteMany({ hubId });
await Hub.deleteOne({ hubId });
......
......@@ -197,6 +197,7 @@ const DoctorMenuContainer = (props : DoctorMenuProps) => {
});
if(result.statusText === 'OK') {
Alert.onSuccess('환자에게 담당의 등록 요청을 전송했습니다.', () => null);
setNewPatientRegisterModal(false);
} else {
Alert.onError('환자에게 담당의 등록 요청을 실패했습니다.', () => null);
}
......