-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GWL-176] Profile API를 구현한다. #204
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
60646c8
chore: ipa 배포 링크 추가
wonholim 87d9b17
feat: profile dto 생성
wonholim 75d1f71
feat: exception 구현
wonholim f004901
chore: post 엔티디 수정
wonholim 24482d0
feat: profile Rest API 구현, Create 부분은 제거
wonholim c14e05f
chore: createUser 메서드에 profileImage 추가
wonholim e4e0288
chore: getProfile 수정 및 구현
wonholim df92c85
chore: swagger API response 부분 수정
wonholim 02c36fc
chore: profiles 컨트롤러 수정
wonholim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,52 @@ | ||
import { Profile } from '../entities/profiles.entity'; | ||
import { PickType } from '@nestjs/swagger'; | ||
import { Post } from '../../posts/entities/posts.entity'; | ||
|
||
export class GetResPostUrl extends PickType(Post, ['id', 'postUrl']) {} | ||
|
||
class GetResProfile extends PickType(Profile, [ | ||
'nickname', | ||
'gender', | ||
'birthdate', | ||
'publicId', | ||
'profileImage', | ||
]) {} | ||
|
||
export const GetProfileAndPosts = () => { | ||
return { | ||
example: { | ||
code: null, | ||
errorMessage: null, | ||
data: { | ||
profile: { | ||
nickname: '닉네임', | ||
gender: '남자', | ||
birthdate: '2021-01-01', | ||
publicId: 'adsd2daw-ad2dawd-q1323123', | ||
profileImage: | ||
'https://s3.ap-northeast-2.amazonaws.com/recordapp/adsd2daw-ad2dawd-q1323123', | ||
}, | ||
posts: [ | ||
{ | ||
id: 1, | ||
postUrl: 'https://www.naver.com', | ||
}, | ||
{ | ||
id: 2, | ||
postUrl: 'https://www.naver.com', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
export const SuccessProfile = () => { | ||
return { | ||
example: { | ||
code: null, | ||
errorMessage: null, | ||
data: null, | ||
}, | ||
}; | ||
}; |
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,7 @@ | ||
import { PickType } from '@nestjs/swagger'; | ||
import { Profile } from '../entities/profiles.entity'; | ||
|
||
export class UpdateProfileDto extends PickType(Profile, [ | ||
'nickname', | ||
'profileImage', | ||
]) {} |
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,12 @@ | ||
import { HttpException } from '@nestjs/common'; | ||
|
||
export class PublicIdMismatchException extends HttpException { | ||
constructor() { | ||
const response = { | ||
statusCode: 2030, | ||
message: 'misMatch', | ||
}; | ||
const httpCode = 400; | ||
super(response, httpCode); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,68 @@ | ||
import { Controller } from '@nestjs/common'; | ||
import { | ||
Body, | ||
Controller, | ||
Delete, | ||
Get, | ||
Param, | ||
Patch, | ||
UseGuards, | ||
} from '@nestjs/common'; | ||
import { ProfilesService } from './profiles.service'; | ||
import { UpdateProfileDto } from './dto/update-profile.dto'; | ||
import { ProfileDeco } from './decorator/profile.decorator'; | ||
import { Profile } from './entities/profiles.entity'; | ||
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; | ||
import { AccessTokenGuard } from '../auth/guard/bearerToken.guard'; | ||
import { GetProfileAndPosts, SuccessProfile } from './dto/create-profile.dto'; | ||
|
||
@Controller('profiles') | ||
@ApiTags('Profiles API') | ||
@Controller('api/v1/profiles') | ||
@UseGuards(AccessTokenGuard) | ||
export class ProfilesController { | ||
constructor(private readonly profilesService: ProfilesService) {} | ||
|
||
@ApiOperation({ summary: '프로필을 조회한다.' }) | ||
@ApiResponse({ | ||
status: 200, | ||
description: '프로필 조회 성공', | ||
schema: GetProfileAndPosts(), | ||
}) | ||
@Get(':publicId') | ||
async getMyProfile(@Param('publicId') publicId: string) { | ||
return this.profilesService.getProfileAndPost(publicId); | ||
} | ||
|
||
@ApiOperation({ summary: '프로필을 수정한다. 닉네임 또는 사진' }) | ||
@ApiBody({ type: UpdateProfileDto }) | ||
@ApiResponse({ | ||
status: 200, | ||
description: '프로필 수정 성공', | ||
schema: SuccessProfile(), | ||
}) | ||
@Patch(':profileId') | ||
async updateProfile( | ||
@Param('profileId') profileId: string, | ||
@Body() updateProfileDto: UpdateProfileDto, | ||
@ProfileDeco() profile: Profile, | ||
) { | ||
return this.profilesService.updateProfile( | ||
profileId, | ||
profile.publicId, | ||
updateProfileDto, | ||
); | ||
} | ||
|
||
@ApiOperation({ summary: '프로필을 삭제한다.' }) | ||
@ApiResponse({ | ||
status: 200, | ||
description: '프로필 삭제 성공', | ||
schema: SuccessProfile(), | ||
}) | ||
@Delete(':profileId') | ||
async deleteProfile( | ||
@Param('profileId') profileId: string, | ||
@ProfileDeco() profile: Profile, | ||
) { | ||
return this.profilesService.deleteProfile(profileId, profile.publicId); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳