From 2e2a7460927c6b789ef1ec631c541adc1f8ebd6d Mon Sep 17 00:00:00 2001 From: pp449 Date: Tue, 18 Jul 2023 11:56:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=EB=A7=8C=EC=95=BD=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EA=B0=80=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=EA=B2=BD=EC=9A=B0=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=95=B8=EB=93=A4=EB=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/notice/controller.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/apis/notice/controller.ts b/src/apis/notice/controller.ts index 0827ce6a..83b05fd7 100644 --- a/src/apis/notice/controller.ts +++ b/src/apis/notice/controller.ts @@ -5,6 +5,9 @@ const router = express.Router(); router.get('/', async (req: Request, res: Response) => { try { const major = req.query.major as string; + if (major === undefined) { + res.status(404).json('학과를 입력해주세요'); + } const notices = await getNotices(major); res.json(notices); } catch (err) { From 406bedf715a54c1520e356c4873e8a56c041fa9d Mon Sep 17 00:00:00 2001 From: pp449 Date: Tue, 18 Jul 2023 12:00:48 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20db=20=EC=BF=BC=EB=A6=AC=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=EA=B0=92=EC=9D=B4=20=EC=9E=88=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=EC=97=90=EB=A7=8C=20=EA=B0=92=EC=9D=84=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/notice/service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apis/notice/service.ts b/src/apis/notice/service.ts index 8b894d56..46e11400 100644 --- a/src/apis/notice/service.ts +++ b/src/apis/notice/service.ts @@ -9,7 +9,7 @@ export const getNotices = async (department: string): Promise => { const getNoticesQuery = `SELECT * FROM ${tableName}`; db.query(getNoticesQuery, (err: Error, res: Notice[]) => { if (err) reject(err); - notices.push(...res); + if (res !== undefined && res.length > 0) notices.push(...res); resolve(); }); }); @@ -19,5 +19,6 @@ export const getNotices = async (department: string): Promise => { getNoticesFromTable(`${department}고정`), getNoticesFromTable(`${department}일반`), ]); + return notices; };