diff --git a/src/controllers/userController.ts b/src/controllers/userController.ts index 3b92efb..e19b368 100644 --- a/src/controllers/userController.ts +++ b/src/controllers/userController.ts @@ -35,6 +35,7 @@ import SocialLoginDto from '../intefaces/user/SocialLoginDto'; import LoginResponseDto from '../intefaces/user/LoginResponseDto'; import { SocialVendor } from '../models/socialVendor'; import IUser from '../models/interface/IUser'; +import {AgeGroup, AgeGroupKey} from '../models/user/ageGroup'; /** * @route GET /email @@ -185,7 +186,7 @@ const postUser = async ( email: req.body.email, password: req.body.password, nickname: req.body.nickname, - birthday: req.body.birthday, + ageGroup: AgeGroup[req.body.ageGroup], gender: req.body.gender, profileImgUrl: (req?.file as Express.MulterS3.File)?.location }; diff --git a/src/intefaces/createUserCommand.ts b/src/intefaces/createUserCommand.ts index 6be7f92..d4b2eff 100644 --- a/src/intefaces/createUserCommand.ts +++ b/src/intefaces/createUserCommand.ts @@ -1,8 +1,10 @@ +import {AgeGroup, AgeGroupKey} from '../models/user/ageGroup'; + interface CreateUserCommand { email: string; password: string; nickname: string; - birthday: string; + ageGroup: AgeGroup; gender: string; profileImgUrl: string; } @@ -11,7 +13,7 @@ interface CreateUserReq { email: string; password: string; nickname: string; - birthday: string; + ageGroup: AgeGroupKey; gender: string; } diff --git a/src/models/user/ageGroup.ts b/src/models/user/ageGroup.ts index d86b873..8996023 100644 --- a/src/models/user/ageGroup.ts +++ b/src/models/user/ageGroup.ts @@ -1,12 +1,14 @@ enum AgeGroup { - CHILDREN = '0-13', // 14세 미만(0-13) - ADOLECENT = '14-19', // 14세 이상(14-19) - TWENTIES = '20-29', // 20대(20-29) - THIRTIES = '30-39', // 30대(30-39) - FOURTIES = '40-49', // 40대(40-49) - FIFTIES = '50-59', // 50대(50-59) - OVER_SIXTIES = '60-', // 60대 이상(60 - ) + CHILDREN = '0-13', + ADOLESCENT = '14-19', + TWENTIES = '20-29', + THIRTIES = '30-39', + FORTIES = '40-49', + FIFTIES = '50-59', + OVER_SIXTIES = '60-', UNDEFINED = '정의 안 함' } -export { AgeGroup }; +type AgeGroupKey = keyof typeof AgeGroup; + +export { AgeGroup, AgeGroupKey }; diff --git a/src/routes/userRouter/index.ts b/src/routes/userRouter/index.ts index 3bc9454..33e5546 100644 --- a/src/routes/userRouter/index.ts +++ b/src/routes/userRouter/index.ts @@ -30,14 +30,6 @@ router.post( UserController.postUser ); -// router.patch( -// '', -// auth, -// upload.single('imgFile'), -// [body('nickname').notEmpty(), body('birthday').notEmpty()], -// UserController.patchUser -// ); - router.post('/social', UserController.socialLogin); router.post( diff --git a/src/services/dto/KakaoResponse.ts b/src/services/dto/KakaoResponse.ts index 758f1cd..aceeeaf 100644 --- a/src/services/dto/KakaoResponse.ts +++ b/src/services/dto/KakaoResponse.ts @@ -50,13 +50,13 @@ const toPiickleAgeGroup = (ageGroup: string): AgeGroup => { case '10~14': return AgeGroup.CHILDREN; case '15~19': - return AgeGroup.ADOLECENT; + return AgeGroup.ADOLESCENT; case '20~29': return AgeGroup.TWENTIES; case '30~39': return AgeGroup.THIRTIES; case '40~49': - return AgeGroup.FOURTIES; + return AgeGroup.FORTIES; case '50~59': return AgeGroup.FIFTIES; case '60~69': diff --git a/src/services/dto/NaverResponse.ts b/src/services/dto/NaverResponse.ts index 5b63071..46f4fc4 100644 --- a/src/services/dto/NaverResponse.ts +++ b/src/services/dto/NaverResponse.ts @@ -45,13 +45,13 @@ const toPiickleAgeGroup = (age?: string): AgeGroup => { switch (age) { case '0-9': case '10-19': - return AgeGroup.ADOLECENT; + return AgeGroup.ADOLESCENT; case '20-29': return AgeGroup.TWENTIES; case '30-39': return AgeGroup.THIRTIES; case '40-49': - return AgeGroup.FOURTIES; + return AgeGroup.FORTIES; case '50-59': return AgeGroup.FIFTIES; case '60-': diff --git a/src/services/userService.ts b/src/services/userService.ts index 7dc586e..081af64 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -18,8 +18,6 @@ import { UserBookmarkInfo } from '../intefaces/user/UserBookmarkInfo'; import Bookmark from '../models/bookmark'; import PreUser from '../models/preUser'; import Card, { CardDocument } from '../models/card'; -// import { UpdateUserDto } from '../intefaces/user/UpdateUserDto'; -import util from '../modules/util'; import QuitLog from '../models/quitLog'; const isEmailExisting = async (email: string): Promise => { @@ -46,7 +44,7 @@ const createUser = async (command: CreateUserCommand) => { email, password, nickname, - birthday: birthStr, + ageGroup, gender, profileImgUrl: profileImageUrl } = command; @@ -56,7 +54,7 @@ const createUser = async (command: CreateUserCommand) => { email, hashedPassword: hashSync(password, 10), nickname, - birthday: util.stringToDate(birthStr), + ageGroup, gender, profileImageUrl }); @@ -64,19 +62,6 @@ const createUser = async (command: CreateUserCommand) => { return user; }; -// const patchUser = async (updateUserDto: UpdateUserDto) => { -// const user = await User.findById(updateUserDto.id); -// if (!user) { -// throw new IllegalArgumentException('해당 id의 유저가 존재하지 않습니다.'); -// } -// const { nickname, profileImgUrl, birthday, gender } = updateUserDto; -// user.nickname = nickname; -// user.birthday = util.stringToDate(birthday); -// user.profileImageUrl = profileImgUrl ? profileImgUrl : user.profileImageUrl; -// user.gender = gender ? gender : '기타'; -// await user.save(); -// }; - const loginUser = async ( userLoginDto: UserLoginDto ): Promise => { @@ -248,7 +233,6 @@ const deleteUser = async (userId: Types.ObjectId, reasons: string[]) => { export { isEmailExisting, createUser, - // patchUser, loginUser, findUserById, updateNickname,