Skip to content

Commit

Permalink
[FEAT] 회원가입 기능 연령대 반영 (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyY00n committed Jul 10, 2023
1 parent d1509be commit c63caba
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
};
Expand Down
6 changes: 4 additions & 2 deletions src/intefaces/createUserCommand.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Expand All @@ -11,7 +13,7 @@ interface CreateUserReq {
email: string;
password: string;
nickname: string;
birthday: string;
ageGroup: AgeGroupKey;
gender: string;
}

Expand Down
18 changes: 10 additions & 8 deletions src/models/user/ageGroup.ts
Original file line number Diff line number Diff line change
@@ -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 };
8 changes: 0 additions & 8 deletions src/routes/userRouter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/services/dto/KakaoResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
4 changes: 2 additions & 2 deletions src/services/dto/NaverResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-':
Expand Down
20 changes: 2 additions & 18 deletions src/services/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> => {
Expand All @@ -46,7 +44,7 @@ const createUser = async (command: CreateUserCommand) => {
email,
password,
nickname,
birthday: birthStr,
ageGroup,
gender,
profileImgUrl: profileImageUrl
} = command;
Expand All @@ -56,27 +54,14 @@ const createUser = async (command: CreateUserCommand) => {
email,
hashedPassword: hashSync(password, 10),
nickname,
birthday: util.stringToDate(birthStr),
ageGroup,
gender,
profileImageUrl
});
await user.save();
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<PostBaseResponseDto> => {
Expand Down Expand Up @@ -248,7 +233,6 @@ const deleteUser = async (userId: Types.ObjectId, reasons: string[]) => {
export {
isEmailExisting,
createUser,
// patchUser,
loginUser,
findUserById,
updateNickname,
Expand Down

0 comments on commit c63caba

Please sign in to comment.