Skip to content

Commit

Permalink
Merge pull request #24 from O-dar/feature/#4/user_account
Browse files Browse the repository at this point in the history
[FEAT] #4 - 사용자 정보조회 생년월일에서 만나이로 수정
  • Loading branch information
jung0115 authored Aug 8, 2023
2 parents 52ad890 + 041716a commit 5a8f682
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/app/User/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down

0 comments on commit 5a8f682

Please sign in to comment.