-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f94b77
commit cea7650
Showing
8 changed files
with
211 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsString } from 'class-validator'; | ||
|
||
enum GenderEnum { | ||
female = '여자', | ||
male = '남자', | ||
none = '논바이너리', | ||
} | ||
|
||
enum AgeRangeEnum { | ||
early_twenties = '20대 초반', | ||
late_twenties = '20대 후반', | ||
early_thirties = '30대 초반', | ||
late_thirties = '30대 후반', | ||
early_forties = '40대 초반', | ||
late_forties = '40대 후반', | ||
early_fifties = '50대 초반', | ||
late_fifties = '50대 후반', | ||
} | ||
|
||
export class UpdateUserInfoDto { | ||
@ApiProperty({ | ||
example: '남자', | ||
description: '성별', | ||
required: true, | ||
enum: GenderEnum, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
gender: string; | ||
|
||
@ApiProperty({ | ||
example: '20대 초반', | ||
description: '나이', | ||
required: true, | ||
enum: AgeRangeEnum, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
ageRange: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsString } from 'class-validator'; | ||
|
||
enum GenderEnum { | ||
female = '여자', | ||
male = '남자', | ||
none = '논바이너리', | ||
} | ||
|
||
enum AgeRangeEnum { | ||
early_twenties = '20대 초반', | ||
late_twenties = '20대 후반', | ||
early_thirties = '30대 초반', | ||
late_thirties = '30대 후반', | ||
early_forties = '40대 초반', | ||
late_forties = '40대 후반', | ||
early_fifties = '50대 초반', | ||
late_fifties = '50대 후반', | ||
} | ||
|
||
export class GetUserInfoDto { | ||
@ApiProperty({ | ||
example: '남자', | ||
description: '성별', | ||
required: true, | ||
enum: GenderEnum, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
gender: string; | ||
|
||
@ApiProperty({ | ||
example: '20대 초반', | ||
description: '나이', | ||
required: true, | ||
enum: AgeRangeEnum, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
ageRange: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Body, Controller, Get, Patch, UseGuards } from '@nestjs/common'; | ||
import { | ||
ApiBearerAuth, | ||
ApiOkResponse, | ||
ApiOperation, | ||
ApiTags, | ||
} from '@nestjs/swagger'; | ||
import { JwtAuthGuard } from 'src/auth/guard/jwt-auth.guard'; | ||
import { GetUser } from './decorator/get-user.decorator'; | ||
import { UserService } from './user.service'; | ||
import { UpdateUserInfoDto } from './dto/req/UpdateUserInfo.dto'; | ||
import { GetUserInfoDto } from './dto/res/GetUserInfo.dto'; | ||
|
||
@Controller('user') | ||
@ApiTags('user') | ||
export class UserController { | ||
constructor(private readonly userService: UserService) {} | ||
|
||
@ApiOperation({ | ||
summary: 'Get user info(gender, ageRange)', | ||
description: 'Get user info(gender, ageRange)', | ||
}) | ||
@ApiOkResponse({ | ||
type: GetUserInfoDto, | ||
description: 'Return user info(gender, ageRange)', | ||
}) | ||
@ApiBearerAuth() | ||
@Get() | ||
@UseGuards(JwtAuthGuard) | ||
getUserInfo(@GetUser() userUuid: string) { | ||
return this.userService.getUserInfo(userUuid); | ||
} | ||
|
||
@ApiOperation({ | ||
summary: 'Update user info(gender, ageRange)', | ||
description: 'Update user info(gender, ageRange)', | ||
}) | ||
@ApiOkResponse({ | ||
type: GetUserInfoDto, | ||
description: 'Return updated user info(gender, ageRange)', | ||
}) | ||
@ApiBearerAuth() | ||
@Patch() | ||
@UseGuards(JwtAuthGuard) | ||
updateUserInfo( | ||
@GetUser() userUuid: string, | ||
@Body() { gender, ageRange }: UpdateUserInfoDto, | ||
) { | ||
return this.userService.updateUserInfo(gender, ageRange, userUuid); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { UserRepository } from './user.repository'; | ||
|
||
@Injectable() | ||
export class UserService { | ||
constructor(private readonly userRepository: UserRepository) {} | ||
|
||
async getUserInfo(userUuid: string) { | ||
return await this.userRepository.getUserInfo(userUuid); | ||
} | ||
|
||
async updateUserInfo(gender: string, ageRange: string, userUuid: string) { | ||
return await this.userRepository.updateUserInfo(gender, ageRange, userUuid); | ||
} | ||
} |