From 2b668091dff89217bed1ae5eddc85a2ff6390a7b Mon Sep 17 00:00:00 2001 From: Youngho Date: Wed, 11 May 2022 17:14:17 +0900 Subject: [PATCH 01/20] =?UTF-8?q?req.files=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/multer.ts | 2 +- backend/src/controllers/workdiary.controller.ts | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/backend/src/controllers/multer.ts b/backend/src/controllers/multer.ts index 7bc13c8..926d57f 100644 --- a/backend/src/controllers/multer.ts +++ b/backend/src/controllers/multer.ts @@ -9,7 +9,7 @@ const upload = multer({ contentType: multerS3.AUTO_CONTENT_TYPE, acl: 'public-read', - key: function (reqest, file, cb) { + key: function (req, file, cb) { // console.log(req) cb(null, `workdiary/${Date.now()}_${file.originalname}`) }, diff --git a/backend/src/controllers/workdiary.controller.ts b/backend/src/controllers/workdiary.controller.ts index 43b3678..442be2d 100644 --- a/backend/src/controllers/workdiary.controller.ts +++ b/backend/src/controllers/workdiary.controller.ts @@ -16,10 +16,6 @@ const uploadImg = upload.upload.array('img'); const writeWorkdiary = async (req:Request, res:Response, next:NextFunction) => { console.log(req.body) - // console.log(req) - // console.log("-------------------") - // console.log((req as MulterRequest)) - uploadImg(req,res,async (err) => { if(err){ From c89df8221cec3847da20609e8115a66557cd5219 Mon Sep 17 00:00:00 2001 From: Youngho Date: Wed, 11 May 2022 17:26:40 +0900 Subject: [PATCH 02/20] =?UTF-8?q?alarm=20=EB=A1=9C=EA=B7=B8=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/alarm.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/controllers/alarm.controller.ts b/backend/src/controllers/alarm.controller.ts index 5738fe3..75e5280 100644 --- a/backend/src/controllers/alarm.controller.ts +++ b/backend/src/controllers/alarm.controller.ts @@ -28,7 +28,7 @@ const upload = multer({ }) const sendAlarm = async (req:Request, res:Response, next:NextFunction) => { - + console.log(req) const alarmCode: string = req.body.alarmCode const alarmText: string = req.body.alarmText From 80038343fd61c8efa90af0f2188b00ef1073d7e1 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Fri, 20 May 2022 14:06:19 +0900 Subject: [PATCH 03/20] =?UTF-8?q?add=20feature:=20=EB=AA=A8=EB=93=A0=20API?= =?UTF-8?q?=20=ED=86=A0=ED=81=B0=20=EC=9D=B8=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/routes/bs.route.ts | 15 ++++++++------- backend/src/routes/parent.route.ts | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/src/routes/bs.route.ts b/backend/src/routes/bs.route.ts index 19230e3..98cfe7b 100644 --- a/backend/src/routes/bs.route.ts +++ b/backend/src/routes/bs.route.ts @@ -3,20 +3,21 @@ import BSController from '../controllers/bs.controller'; import mappingController from '../controllers/mapping.controller'; import alarmController from "../controllers/alarm.controller"; import workdiaryController from "../controllers/workdiary.controller" +import Authorization from '../middleware/authMiddleware'; const router = express.Router(); -router.post('/info/:userId', BSController.inputBSInfo); -router.get('/info/:bsId', BSController.getBSInfo); -router.patch('/info/:bsId', BSController.updateBSInfo); +router.post('/info/:userId', Authorization, BSController.inputBSInfo); +router.get('/info/:bsId', Authorization, BSController.getBSInfo); +router.patch('/info/:bsId', Authorization, BSController.updateBSInfo); -router.post('/mapping/:bsId', BSController.mappingRequest); -router.get('/mapping/:bsId', mappingController.findParentList) +router.post('/mapping/:bsId', Authorization, BSController.mappingRequest); +router.get('/mapping/:bsId', Authorization, mappingController.findParentList) -router.post('/alarm/:mappingId', alarmController.upload.single("img"), alarmController.sendAlarm); +router.post('/alarm/:mappingId', Authorization, alarmController.upload.single("img"), alarmController.sendAlarm); -router.post('/diary/:mappingId', workdiaryController.writeWorkdiary) //,workdiaryController.upload.array("img") +router.post('/diary/:mappingId', Authorization, workdiaryController.writeWorkdiary) //,workdiaryController.upload.array("img") router.get('/test',(req,res) => res.send("test1")) export = router; \ No newline at end of file diff --git a/backend/src/routes/parent.route.ts b/backend/src/routes/parent.route.ts index 7d202fa..0edf1e4 100644 --- a/backend/src/routes/parent.route.ts +++ b/backend/src/routes/parent.route.ts @@ -7,10 +7,10 @@ const router = express.Router(); router.post('/info/:id', Authorization, parentController.createParentInfo); router.get('/info/:parentId', Authorization, parentController.getParentInfo); router.patch('/info/:parentId', Authorization, parentController.editParentInfo); -router.get('/main/:parentId', parentController.getMainPage); -router.patch('/mapping/acceptance/:mappingId', parentController.acceptMapping); -router.delete('/mapping/rejection/:mappingId', parentController.rejectMapping); -router.get('/diary/:mappingId', parentController.getDailyDiary) -router.post('/calendar/:mappingId', parentController.getCalendarDiary) +router.get('/main/:parentId', Authorization, parentController.getMainPage); +router.patch('/mapping/acceptance/:mappingId', Authorization, parentController.acceptMapping); +router.delete('/mapping/rejection/:mappingId', Authorization, parentController.rejectMapping); +router.get('/diary/:mappingId', Authorization, parentController.getDailyDiary) +router.post('/calendar/:mappingId', Authorization, parentController.getCalendarDiary) export = router; From 32998f9178682dc48299ca3f0c1cff14f8128bbd Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Fri, 20 May 2022 18:23:32 +0900 Subject: [PATCH 04/20] =?UTF-8?q?hotifx:=20=EB=82=A0=EC=A7=9C=EB=B3=84=20?= =?UTF-8?q?=ED=87=B4=EA=B7=BC=EC=9D=BC=EC=A7=80=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/parent.controller.ts | 47 +++++++++++++++++--- backend/src/entity/Alarm.ts | 22 +++++++++ 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index dff273c..26578fd 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -4,6 +4,7 @@ import { Parent } from '../entity/Parent'; import { Mapping } from "../entity/Mapping"; import { WorkDiary } from "../entity/WorkDiary"; import { WorkDiaryImg } from "../entity/WorkDiaryImg"; +import { Alarm } from "../entity/Alarm"; const getParentInfo = async (req: Request, res: Response, next: NextFunction) => { const parent_id: number = +req.params.parentId; @@ -191,6 +192,8 @@ const getDailyDiary = async (req: Request, res: Response, next: NextFunction) => // mappingId를 이용하여 금일 퇴근일지 가져오기 const daily_work_diary = await WorkDiary.findDiarybyMappingId(mappingId); + const daily_alarm_list = await Alarm.findAlarmbyMappingId(mappingId); + if (daily_work_diary === undefined) { return res.status(404).json({ message: "금일 작성된 퇴근일지가 존재하지 않습니다." @@ -202,7 +205,8 @@ const getDailyDiary = async (req: Request, res: Response, next: NextFunction) => .then((result) => { return res.status(200).json({ dailyDiary: daily_work_diary, - dailyImageList: result + dailyImageList: result, + dailyAlarmList: daily_alarm_list }) }) .catch((err) => { @@ -217,19 +221,48 @@ const getCalendarDiary = async (req: Request, res: Response, next: NextFunction) // mappingId, 날짜를 이용하여 특정 날짜의 퇴근일지 가져오기 const calendar_work_diary = await WorkDiary.findCalendarDiary(mappingId, date); + const calendar_alarm_list = await Alarm.findCalendarAlarmList(mappingId, date); - if (calendar_work_diary === undefined) { - return res.status(404).json({ - message: "해당 날짜에 작성된 퇴근일지가 존재하지 않습니다." + // 알람도 없고 퇴근 일지도 없는 경우 + if (calendar_work_diary === undefined && calendar_alarm_list.length === 0) { + return res.status(200).json({ + CalendarDiary: { + issue: "" + }, + CalendarImageList : [], + CalendarAlarmList: [] }) - } - else { + + } // 알람은 없고 퇴근 일지만 있는 경우 + else if (calendar_work_diary !== undefined && calendar_alarm_list === []) { // 가져온 퇴근일지 ID, 날짜를 이용하여 특정 날짜에 작성된 퇴근일지 이미지 리스트 가져오기 await WorkDiaryImg.findImgUsingIdAndDate(calendar_work_diary.diaryId, date) .then((result) => { return res.status(200).json({ CalendarDiary: calendar_work_diary, - CalendarImageList: result + CalendarImageList: result, + CalendarAlarmList: [] + }) + }) + .catch((err) => { + res.status(400).json(err); + }) + } // 알람은 있는데 퇴근 일지는 없는 경우 + else if (calendar_work_diary === undefined && calendar_alarm_list !== []) { + return res.status(200).json({ + CalendarAlarmList: calendar_alarm_list, + CalendarDiary: {issue: ""}, + CalendarImageList: [] + }) + + } // 알람, 퇴근일지 전부 있는 경우 + else if (calendar_work_diary !== undefined && calendar_alarm_list !== []) { + await WorkDiaryImg.findImgUsingIdAndDate(calendar_work_diary.diaryId, date) + .then((result) => { + return res.status(200).json({ + CalendarDiary: calendar_work_diary, + CalendarImageList: result, + CalendarAlarmList: calendar_alarm_list }) }) .catch((err) => { diff --git a/backend/src/entity/Alarm.ts b/backend/src/entity/Alarm.ts index 63c6060..e79ddba 100644 --- a/backend/src/entity/Alarm.ts +++ b/backend/src/entity/Alarm.ts @@ -27,5 +27,27 @@ export class Alarm extends BaseEntity { @JoinColumn({name: "mappingId"}) mapping: Mapping + // 당일 작성된 알람 이미지 리스트 가져오기 + static async findAlarmbyMappingId(mappingId: number) { + + const date = new Date(); + let year: number = date.getFullYear(); + let month: string = ("0" + (1 + date.getMonth())).slice(-2); + let day: string = ("0" + date.getDate()).slice(-2); + + return await this.createQueryBuilder("alarm") + .where("alarm.mappingId = :mappingId", {mappingId: mappingId}) + .andWhere("DATE_FORMAT(alarm.createdAt, '%Y-%m-%d') = :date", {date: year + "-" + month + "-" + day}) + .getMany(); + } + + // 알람 테이블에서 클릭한 날짜에 저장된 이미지 가져오기 + static async findCalendarAlarmList(mappingId: number, date: string) { + + return await this.createQueryBuilder("alarm") + .where("alarm.mappingId = :mappingId", {mappingId: mappingId}) + .andWhere("DATE_FORMAT(alarm.createdAt, '%Y-%m-%d') = :date", {date: date}) + .getMany(); + } } \ No newline at end of file From 64b09e99ad9a52a55ed445e87f00ac76c139be5f Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 14:36:56 +0900 Subject: [PATCH 05/20] =?UTF-8?q?add=20feature:=20=EC=98=A8=EC=8A=B5?= =?UTF-8?q?=EB=8F=84=20=EC=84=BC=EC=84=9C=20=EA=B0=90=EC=A7=80=20API=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/parent.controller.ts | 20 +++++++++++++++++++- backend/src/entity/Mapping.ts | 3 +++ backend/src/routes/parent.route.ts | 6 ++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index 26578fd..eba6eeb 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -271,4 +271,22 @@ const getCalendarDiary = async (req: Request, res: Response, next: NextFunction) } } -export default {getParentInfo, editParentInfo, createParentInfo, getMainPage, acceptMapping, rejectMapping, getDailyDiary, getCalendarDiary}; \ No newline at end of file +const getSensorInfo = async (req: Request, res: Response, next: NextFunction) => { + const mappingInfo = await Mapping.find({mappingId: 1}) + + return res.status(200).json({ + alert: mappingInfo[0].alert + }) + +} + +const updateSensorInfo = async (req: Request, res: Response, next: NextFunction) => { + await Mapping.update({mappingId: 1}, {alert: false}) + .then((result) => { + res.status(200).json({ + message: "success" + }) + }) +} + +export default {getParentInfo, editParentInfo, createParentInfo, getMainPage, acceptMapping, rejectMapping, getDailyDiary, getCalendarDiary, getSensorInfo, updateSensorInfo}; \ No newline at end of file diff --git a/backend/src/entity/Mapping.ts b/backend/src/entity/Mapping.ts index 408d6a8..dba315e 100644 --- a/backend/src/entity/Mapping.ts +++ b/backend/src/entity/Mapping.ts @@ -49,6 +49,9 @@ export class Mapping extends BaseEntity { ) diary: WorkDiary[]; + @Column({default: false}) + alert: boolean + // 부모 ID를 기준으로 매핑되어 있는 보모 정보를 반환 static async findMappingList(parentId: number) { return await this.createQueryBuilder("mapping") diff --git a/backend/src/routes/parent.route.ts b/backend/src/routes/parent.route.ts index 0edf1e4..2a19ce0 100644 --- a/backend/src/routes/parent.route.ts +++ b/backend/src/routes/parent.route.ts @@ -10,7 +10,9 @@ router.patch('/info/:parentId', Authorization, parentController.editParentInfo); router.get('/main/:parentId', Authorization, parentController.getMainPage); router.patch('/mapping/acceptance/:mappingId', Authorization, parentController.acceptMapping); router.delete('/mapping/rejection/:mappingId', Authorization, parentController.rejectMapping); -router.get('/diary/:mappingId', Authorization, parentController.getDailyDiary) -router.post('/calendar/:mappingId', Authorization, parentController.getCalendarDiary) +router.get('/diary/:mappingId', Authorization, parentController.getDailyDiary); +router.post('/calendar/:mappingId', Authorization, parentController.getCalendarDiary); +router.get('/sensor', Authorization, parentController.getSensorInfo); +router.patch('/sensor', Authorization, parentController.updateSensorInfo); export = router; From 4589d3b2819264f3bbc9a4c32638757a2cbf5b91 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 14:46:53 +0900 Subject: [PATCH 06/20] =?UTF-8?q?add=20feature:=20=EB=9D=BC=EC=A6=88?= =?UTF-8?q?=EB=B2=A0=EB=A6=AC=ED=8C=8C=EC=9D=B4=20=EC=98=A8=EC=8A=B5?= =?UTF-8?q?=EB=8F=84=20=EC=9D=B4=EC=83=81=EA=B0=90=EC=A7=80=20=EC=8B=9C=20?= =?UTF-8?q?alert=20=EC=86=8D=EC=84=B1=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/parent.controller.ts | 11 ++++++++++- backend/src/routes/parent.route.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index eba6eeb..ffa253f 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -289,4 +289,13 @@ const updateSensorInfo = async (req: Request, res: Response, next: NextFunction) }) } -export default {getParentInfo, editParentInfo, createParentInfo, getMainPage, acceptMapping, rejectMapping, getDailyDiary, getCalendarDiary, getSensorInfo, updateSensorInfo}; \ No newline at end of file +const updateSensorAlert = async (req: Request, res: Response, next: NextFunction) => { + await Mapping.update({mappingId: 1}, {alert: true}) + .then((result) => { + res.status(200).json({ + message: "success" + }) + }) +} + +export default {getParentInfo, editParentInfo, createParentInfo, getMainPage, acceptMapping, rejectMapping, getDailyDiary, getCalendarDiary, getSensorInfo, updateSensorInfo, updateSensorAlert}; \ No newline at end of file diff --git a/backend/src/routes/parent.route.ts b/backend/src/routes/parent.route.ts index 2a19ce0..2c54441 100644 --- a/backend/src/routes/parent.route.ts +++ b/backend/src/routes/parent.route.ts @@ -14,5 +14,6 @@ router.get('/diary/:mappingId', Authorization, parentController.getDailyDiary); router.post('/calendar/:mappingId', Authorization, parentController.getCalendarDiary); router.get('/sensor', Authorization, parentController.getSensorInfo); router.patch('/sensor', Authorization, parentController.updateSensorInfo); +router.patch('/sensor/alert', Authorization, parentController.updateSensorAlert); export = router; From 420a61bbf4c5ff7359bae4af9060e6d4ed0c2e13 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 15:24:08 +0900 Subject: [PATCH 07/20] =?UTF-8?q?IoT=20API=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/routes/parent.route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/routes/parent.route.ts b/backend/src/routes/parent.route.ts index 2c54441..8454351 100644 --- a/backend/src/routes/parent.route.ts +++ b/backend/src/routes/parent.route.ts @@ -14,6 +14,6 @@ router.get('/diary/:mappingId', Authorization, parentController.getDailyDiary); router.post('/calendar/:mappingId', Authorization, parentController.getCalendarDiary); router.get('/sensor', Authorization, parentController.getSensorInfo); router.patch('/sensor', Authorization, parentController.updateSensorInfo); -router.patch('/sensor/alert', Authorization, parentController.updateSensorAlert); +router.patch('/sensor/alert', parentController.updateSensorAlert); export = router; From d3bb8bcceff3f0962f1cdf92c649fb4afdd0f547 Mon Sep 17 00:00:00 2001 From: Youngho Date: Sat, 21 May 2022 16:06:46 +0900 Subject: [PATCH 08/20] =?UTF-8?q?findParentList=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/mapping.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/controllers/mapping.controller.ts b/backend/src/controllers/mapping.controller.ts index 42ae979..3f1abbe 100644 --- a/backend/src/controllers/mapping.controller.ts +++ b/backend/src/controllers/mapping.controller.ts @@ -6,7 +6,7 @@ const findParentList = async (req:Request, res: Response, next: NextFunction) => try{ const bsId : number = +req.params.bsId; - await BabySitter.findById(bsId) + // await BabySitter.findById(bsId) const result = await Mapping.findMappingParentList(bsId); const returnData = [] @@ -17,7 +17,7 @@ const findParentList = async (req:Request, res: Response, next: NextFunction) => result.map((value: any, index: number) => { console.log(typeof(value)) - returnData.push(value.parent) + returnData.push(value) }) res.status(200).json(returnData) From de797687e015bf769ae9061ccd626c5e0354b456 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 16:52:16 +0900 Subject: [PATCH 09/20] =?UTF-8?q?hotfix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=20=EB=84=98=EA=B2=A8=EC=A3=BC=EB=8A=94=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/user.controller.ts | 84 +++++++++++++++------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/backend/src/controllers/user.controller.ts b/backend/src/controllers/user.controller.ts index de70273..b24ac43 100644 --- a/backend/src/controllers/user.controller.ts +++ b/backend/src/controllers/user.controller.ts @@ -2,6 +2,8 @@ import { Request, Response, NextFunction } from "express"; import { User } from '../entity/User'; import bcrypt from "bcrypt"; import * as jwt from 'jsonwebtoken'; +import { Parent } from "../entity/Parent"; +import { BabySitter } from "../entity/BabySitter"; const signup = async (req: Request, res: Response, next: NextFunction) => { const saltRound = 10; @@ -51,7 +53,6 @@ const signup = async (req: Request, res: Response, next: NextFunction) => { const login = async (req: Request, res: Response, next: NextFunction) => { const {email, password} = req.body; - const user = await User.find({ email: email }) @@ -62,31 +63,66 @@ const login = async (req: Request, res: Response, next: NextFunction) => { }) } else { - const check = await bcrypt.compare(password, user[0].password); - - if(check) { // 패스워드 일치 시 토큰 발행 - const token = jwt.sign({ - type: 'JWT', - email: email, - }, process.env.SECRET_KEY, { - expiresIn: '24h', // 만료시간 24h - issuer: 'icare', - } - ); - - res.status(200).json({ - success: true, - message: "토큰 발행 완료", - token: token, - userInfo: user - }); + if (user[0].code === 1) { + const parent = await Parent.find({user: user[0]}) + const check = await bcrypt.compare(password, user[0].password); + + if(check) { // 패스워드 일치 시 토큰 발행 + const token = jwt.sign({ + type: 'JWT', + email: email, + }, process.env.SECRET_KEY, { + expiresIn: '24h', // 만료시간 24h + issuer: 'icare', + } + ); + + res.status(200).json({ + success: true, + message: "토큰 발행 완료", + token: token, + userInfo: user, + parentId: parent[0].parentId + }); + + } + else { + res.status(400).json({ + message: "비밀번호가 일치하지 않습니다." + }) + } } - else { - res.status(400).json({ - message: "비밀번호가 일치하지 않습니다." - }) - } + else if (user[0].code === 2) { + const sitter = await BabySitter.find({user: user[0]}); + + const check = await bcrypt.compare(password, user[0].password); + + if(check) { // 패스워드 일치 시 토큰 발행 + const token = jwt.sign({ + type: 'JWT', + email: email, + }, process.env.SECRET_KEY, { + expiresIn: '24h', // 만료시간 24h + issuer: 'icare', + } + ); + + res.status(200).json({ + success: true, + message: "토큰 발행 완료", + token: token, + userInfo: user, + sitterId: sitter[0].bsId + }); + + } + else { + res.status(400).json({ + message: "비밀번호가 일치하지 않습니다." + }) + } + } } }; From babd059c4fc69416091ac72403a764ba7160db3b Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 18:05:03 +0900 Subject: [PATCH 10/20] =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/routes/bs.route.ts | 14 +++++++------- backend/src/routes/parent.route.ts | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/backend/src/routes/bs.route.ts b/backend/src/routes/bs.route.ts index 98cfe7b..574d36d 100644 --- a/backend/src/routes/bs.route.ts +++ b/backend/src/routes/bs.route.ts @@ -8,16 +8,16 @@ import Authorization from '../middleware/authMiddleware'; const router = express.Router(); -router.post('/info/:userId', Authorization, BSController.inputBSInfo); -router.get('/info/:bsId', Authorization, BSController.getBSInfo); -router.patch('/info/:bsId', Authorization, BSController.updateBSInfo); +router.post('/info/:userId', BSController.inputBSInfo); +router.get('/info/:bsId', BSController.getBSInfo); +router.patch('/info/:bsId', BSController.updateBSInfo); -router.post('/mapping/:bsId', Authorization, BSController.mappingRequest); -router.get('/mapping/:bsId', Authorization, mappingController.findParentList) +router.post('/mapping/:bsId', BSController.mappingRequest); +router.get('/mapping/:bsId', mappingController.findParentList) -router.post('/alarm/:mappingId', Authorization, alarmController.upload.single("img"), alarmController.sendAlarm); +router.post('/alarm/:mappingId', alarmController.upload.single("img"), alarmController.sendAlarm); -router.post('/diary/:mappingId', Authorization, workdiaryController.writeWorkdiary) //,workdiaryController.upload.array("img") +router.post('/diary/:mappingId', workdiaryController.writeWorkdiary) //,workdiaryController.upload.array("img") router.get('/test',(req,res) => res.send("test1")) export = router; \ No newline at end of file diff --git a/backend/src/routes/parent.route.ts b/backend/src/routes/parent.route.ts index 8454351..b79b378 100644 --- a/backend/src/routes/parent.route.ts +++ b/backend/src/routes/parent.route.ts @@ -4,16 +4,16 @@ import Authorization from '../middleware/authMiddleware'; const router = express.Router(); -router.post('/info/:id', Authorization, parentController.createParentInfo); -router.get('/info/:parentId', Authorization, parentController.getParentInfo); -router.patch('/info/:parentId', Authorization, parentController.editParentInfo); -router.get('/main/:parentId', Authorization, parentController.getMainPage); -router.patch('/mapping/acceptance/:mappingId', Authorization, parentController.acceptMapping); -router.delete('/mapping/rejection/:mappingId', Authorization, parentController.rejectMapping); -router.get('/diary/:mappingId', Authorization, parentController.getDailyDiary); -router.post('/calendar/:mappingId', Authorization, parentController.getCalendarDiary); -router.get('/sensor', Authorization, parentController.getSensorInfo); -router.patch('/sensor', Authorization, parentController.updateSensorInfo); +router.post('/info/:id', parentController.createParentInfo); +router.get('/info/:parentId', parentController.getParentInfo); +router.patch('/info/:parentId', parentController.editParentInfo); +router.get('/main/:parentId', parentController.getMainPage); +router.patch('/mapping/acceptance/:mappingId', parentController.acceptMapping); +router.delete('/mapping/rejection/:mappingId', parentController.rejectMapping); +router.get('/diary/:mappingId', parentController.getDailyDiary); +router.post('/calendar/:mappingId', parentController.getCalendarDiary); +router.get('/sensor', parentController.getSensorInfo); +router.patch('/sensor', parentController.updateSensorInfo); router.patch('/sensor/alert', parentController.updateSensorAlert); export = router; From 2301765c33854c7fbfdd66cf8f872c37eba3e481 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 19:54:29 +0900 Subject: [PATCH 11/20] =?UTF-8?q?hotifx:=20=EB=B6=80=EB=AA=A8=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/parent.controller.ts | 6 +++++- backend/src/entity/Parent.ts | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index ffa253f..4eef18d 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -88,6 +88,9 @@ const getMainPage = async (req: Request, res: Response, next: NextFunction) => { const parent_id: number = +req.params.parentId; const existMappingList = await Mapping.findMappingList(parent_id); + + const parentInfo = await Parent.getParentEmail(parent_id); + const parentEmail: string = parentInfo.user['email'] let mapping_info = []; let request_info = []; @@ -117,7 +120,8 @@ const getMainPage = async (req: Request, res: Response, next: NextFunction) => { else if (mapping_info.length === 0 && request_info.length !== 0) { return res.status(200).json({ message: "보모의 매핑 요청 리스트", - request_info + request_info, + inviteEmail: parentEmail }) } // 둘 다 없는 경우 else { diff --git a/backend/src/entity/Parent.ts b/backend/src/entity/Parent.ts index 1544434..afec400 100644 --- a/backend/src/entity/Parent.ts +++ b/backend/src/entity/Parent.ts @@ -44,4 +44,11 @@ export class Parent extends BaseEntity { requestToParent => requestToParent.parent,{ nullable: false, onDelete: 'CASCADE' } ) request: RequestToParent[]; + + static async getParentEmail(parentId: number){ + return await this.createQueryBuilder("parent") + .leftJoinAndSelect("parent.user", "user") + .where("parent.parentId = :parentId", {parentId: parentId}) + .getOne(); + } } From 75e8ba834b9441768f6092233e2f009fe82e9cfa Mon Sep 17 00:00:00 2001 From: Youngho Date: Sat, 21 May 2022 20:01:26 +0900 Subject: [PATCH 12/20] =?UTF-8?q?api=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/bs.controller.ts | 11 ++++++----- backend/src/entity/BabySitter.ts | 8 ++++++++ backend/src/entity/Mapping.ts | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/src/controllers/bs.controller.ts b/backend/src/controllers/bs.controller.ts index b7c7f30..eb5b5b6 100644 --- a/backend/src/controllers/bs.controller.ts +++ b/backend/src/controllers/bs.controller.ts @@ -32,18 +32,19 @@ const inputBSInfo = async (req:Request, res:Response, next:NextFunction) => { .then((result) => { res.status(201).json(result); }); - } - - + } } const getBSInfo = async (req:Request, res:Response, next:NextFunction) => { - // req.params.userId -> string이라 number로 변환 + let returnData = {} + const bsId: number = +req.params.bsId; - const bs = await BabySitter.findOne({bsId: bsId}); + const bs = await BabySitter.getBsInfomation(bsId); + console.log(bs.user) if (bs) { + // returnData['bs'] = bs.Babysitter res.status(200).json({bs}) } else { diff --git a/backend/src/entity/BabySitter.ts b/backend/src/entity/BabySitter.ts index 6aa1d12..bfeea2e 100644 --- a/backend/src/entity/BabySitter.ts +++ b/backend/src/entity/BabySitter.ts @@ -60,6 +60,14 @@ export class BabySitter extends BaseEntity { return await this.update({bsId:bsId}, data) } + static async getBsInfomation(bsId:number){ + return await this.createQueryBuilder("babySitter") + .leftJoinAndSelect("babySitter.user", "user") + .where("babySitter.bsId = :bsId", { bsId: bsId }) + .select(["babySitter.bsId", "babySitter.age", "babySitter.region", "babySitter.gender","babySitter.career", "user.username"]) + .getOne() + } + static async checkDuple(userId:number){ const result = await this.createQueryBuilder("babySitter") .where("babySitter.userId = :userId", {userId:userId}) diff --git a/backend/src/entity/Mapping.ts b/backend/src/entity/Mapping.ts index dba315e..b566e27 100644 --- a/backend/src/entity/Mapping.ts +++ b/backend/src/entity/Mapping.ts @@ -57,7 +57,7 @@ export class Mapping extends BaseEntity { return await this.createQueryBuilder("mapping") .leftJoinAndSelect("mapping.babySitter", "babySitter") .leftJoinAndSelect("babySitter.user", "user") - .select(["mapping.mappingId", "mapping.status", "babySitter.bsId", "babySitter.age", "babySitter.region", "babySitter.career", "user.username"]) + .select(["mapping.mappingId", "mapping.status", "babySitter.bsId", "babySitter.age","babySitter.gender", "babySitter.region", "babySitter.career", "user.username"]) .where("mapping.parentId = :parentId", { parentId: parentId }) .getMany(); } From 5a7c88b056f6ac822c0613fe6eb033056cbecf1f Mon Sep 17 00:00:00 2001 From: Youngho Date: Sat, 21 May 2022 20:49:22 +0900 Subject: [PATCH 13/20] =?UTF-8?q?nickname=20=EC=A4=91=EB=B3=B5=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/entity/User.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/entity/User.ts b/backend/src/entity/User.ts index 070ba66..9bfbc11 100644 --- a/backend/src/entity/User.ts +++ b/backend/src/entity/User.ts @@ -12,7 +12,7 @@ export class User extends BaseEntity { @Column({nullable : false}) username: string; - @Column({nullable : false, unique: true}) + @Column({nullable : false}) nickname: string; @Column({nullable : false}) From bf6e836e5dcce6787b3b50b017271b1f48c332f3 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 21:42:50 +0900 Subject: [PATCH 14/20] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/parent.controller.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index 4eef18d..bf167b0 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -123,18 +123,13 @@ const getMainPage = async (req: Request, res: Response, next: NextFunction) => { request_info, inviteEmail: parentEmail }) - } // 둘 다 없는 경우 - else { - return res.status(404).json({ - message: "매핑 및 요청 정보 없음" - }) } } - // 존재하지 않는 parentId로 요청 보낸 경우 + // 매핑 정보가 없는 경우 else { - return res.status(400).json({ - message: "Invalid parentId" - }); + return res.status(200).json({ + request_info: [] + }) } From 001de70b7a4e747f7e8383910cf6ed1e793627d4 Mon Sep 17 00:00:00 2001 From: KMUsungwon Date: Sat, 21 May 2022 21:48:29 +0900 Subject: [PATCH 15/20] =?UTF-8?q?=EB=B2=84=EA=B7=B8=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/parent.controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index bf167b0..a3545e6 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -128,7 +128,8 @@ const getMainPage = async (req: Request, res: Response, next: NextFunction) => { // 매핑 정보가 없는 경우 else { return res.status(200).json({ - request_info: [] + request_info: [], + inviteEmail: parentEmail }) } From 790e51a019ce1ba0371b51dc2a5372ff709b2231 Mon Sep 17 00:00:00 2001 From: Youngho Date: Mon, 23 May 2022 17:20:07 +0900 Subject: [PATCH 16/20] =?UTF-8?q?mapping=20status=EA=B5=AC=EB=B3=84=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/mapping.controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/controllers/mapping.controller.ts b/backend/src/controllers/mapping.controller.ts index 3f1abbe..1e56cf4 100644 --- a/backend/src/controllers/mapping.controller.ts +++ b/backend/src/controllers/mapping.controller.ts @@ -17,7 +17,9 @@ const findParentList = async (req:Request, res: Response, next: NextFunction) => result.map((value: any, index: number) => { console.log(typeof(value)) - returnData.push(value) + if(value.status == "2"){ + returnData.push(value) + } }) res.status(200).json(returnData) From 8d243b64251c55783a268abffccdce2708b935a5 Mon Sep 17 00:00:00 2001 From: Youngho Date: Mon, 23 May 2022 17:26:21 +0900 Subject: [PATCH 17/20] =?UTF-8?q?status=20=3D=3D=201=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/mapping.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/controllers/mapping.controller.ts b/backend/src/controllers/mapping.controller.ts index 1e56cf4..bf3b323 100644 --- a/backend/src/controllers/mapping.controller.ts +++ b/backend/src/controllers/mapping.controller.ts @@ -17,7 +17,7 @@ const findParentList = async (req:Request, res: Response, next: NextFunction) => result.map((value: any, index: number) => { console.log(typeof(value)) - if(value.status == "2"){ + if(value.status == "1"){ returnData.push(value) } }) From 3d8132ac3433e604d2152b3ee7737a8dad418a40 Mon Sep 17 00:00:00 2001 From: Youngho Date: Mon, 23 May 2022 21:19:31 +0900 Subject: [PATCH 18/20] mapping id --- backend/src/controllers/parent.controller.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/controllers/parent.controller.ts b/backend/src/controllers/parent.controller.ts index a3545e6..c9fc0a5 100644 --- a/backend/src/controllers/parent.controller.ts +++ b/backend/src/controllers/parent.controller.ts @@ -272,16 +272,15 @@ const getCalendarDiary = async (req: Request, res: Response, next: NextFunction) } const getSensorInfo = async (req: Request, res: Response, next: NextFunction) => { - const mappingInfo = await Mapping.find({mappingId: 1}) + const mappingInfo = await Mapping.find({mappingId: 6}) return res.status(200).json({ alert: mappingInfo[0].alert }) - } const updateSensorInfo = async (req: Request, res: Response, next: NextFunction) => { - await Mapping.update({mappingId: 1}, {alert: false}) + await Mapping.update({mappingId: 6}, {alert: false}) .then((result) => { res.status(200).json({ message: "success" @@ -290,7 +289,7 @@ const updateSensorInfo = async (req: Request, res: Response, next: NextFunction) } const updateSensorAlert = async (req: Request, res: Response, next: NextFunction) => { - await Mapping.update({mappingId: 1}, {alert: true}) + await Mapping.update({mappingId: 6}, {alert: true}) .then((result) => { res.status(200).json({ message: "success" From 6a6d38e69e7256aaf012e05320b2b9a277c8fce1 Mon Sep 17 00:00:00 2001 From: sowish23 Date: Tue, 24 May 2022 20:01:21 +0900 Subject: [PATCH 19/20] set home auth --- application/icare/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/icare/App.tsx b/application/icare/App.tsx index d4955bd..19c22d3 100644 --- a/application/icare/App.tsx +++ b/application/icare/App.tsx @@ -30,7 +30,7 @@ export default function App() { screenOptions={{ headerShown: false }}> - + {/* */} From a4c47ec8d2f8d623580acbe5a743864e043adfcd Mon Sep 17 00:00:00 2001 From: sowish23 Date: Tue, 24 May 2022 20:01:48 +0900 Subject: [PATCH 20/20] set calendar date --- application/icare/src/pages/BabyDiary/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/application/icare/src/pages/BabyDiary/index.tsx b/application/icare/src/pages/BabyDiary/index.tsx index 07e1c58..a179988 100644 --- a/application/icare/src/pages/BabyDiary/index.tsx +++ b/application/icare/src/pages/BabyDiary/index.tsx @@ -42,9 +42,8 @@ const BabyDiary: FC = (props) => { ] useEffect(() => { - console.log(props.route.params) - if(props.route.params.dateString) - setDate(props.route.params.dateString) + if(props.route.params.day.dateString) + setDate(props.route.params.day.dateString) else { var today = new Date() const year = today.getFullYear()