From 041716aeb6ce0d593781594c007ecc941da69f4f Mon Sep 17 00:00:00 2001 From: jung0115 Date: Tue, 8 Aug 2023 16:52:03 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20#04=20-=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=EC=A1=B0=ED=9A=8C=20=EC=83=9D=EB=85=84?= =?UTF-8?q?=EC=9B=94=EC=9D=BC=EC=97=90=EC=84=9C=20=EB=A7=8C=EB=82=98?= =?UTF-8?q?=EC=9D=B4=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/User/userController.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/User/userController.js b/src/app/User/userController.js index 62f6eb1..359dd5f 100644 --- a/src/app/User/userController.js +++ b/src/app/User/userController.js @@ -242,10 +242,21 @@ export const getUserInfo = async (req, res) => { const id = res.locals.user.id; let userInfoById = await userProvider.getUserById(id); + let birthdate = new Date(userInfoById.birthdate); + + // 생일로 만나이 계산 + const today = new Date(); + let age = today.getFullYear() - birthdate.getFullYear(); + const m = today.getMonth() - birthdate.getMonth(); + if (m < 0 || (m === 0 && today.getDate() < birthdate.getDate())) { + age--; + } + //console.log(age); + let userInfo = { // 필요한 정보만 추출 name: userInfoById.name, - birthdate: userInfoById.birthdate, + age: age, profile_img: userInfoById.profile_img, want_days: userInfoById.want_days, desire_start_time: userInfoById.desire_start_time, @@ -254,6 +265,7 @@ export const getUserInfo = async (req, res) => { place_notice: userInfoById.place_notice, place_provide: userInfoById.place_provide }; + let region_id = userInfoById.region_id let job_id = userInfoById.job_id