-
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
[Feature] 상점 아이템 구매코드작성 및 리팩토링 #47
base: develop
Are you sure you want to change the base?
Conversation
src/items/items.controller.ts
Outdated
@@ -30,6 +24,14 @@ export class ItemsController { | |||
return await this.itemsService.getAllItems(); //service에서 아이템 목록을 받아서, 반환(return) | |||
} | |||
|
|||
// Post /items/add 요청 처리 | |||
@Post('add') |
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.
이런 dev용 API는 dev 관련한 API들만 따로 빼놓거나 dev를 엔드포인트에 추가적으로 붙여 주는 게 더 좋을 것 같습니다.
추가로 실제 상용환경의 서비스에선 해당 API를 호출하지 못하도록 막아주는 것이 좋아 보입니다.
레퍼런스
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.
pending이 되어 답장이 안가고 있었네요. 감사합니다! 잘 확인하였습니다 😊
src/items/items.controller.ts
Outdated
async addItem(@Body() addItemDto: ItemChangeStatusDto): Promise<void> { | ||
await this.itemsService.addItem(addItemDto); | ||
} | ||
|
||
// POST /items/buy 요청 처리 | ||
@Post('buy') |
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.
보통 동작에 대한 부분은 api url에 기재하지 않고 HTTP method를 통해서 표현합니다
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.
네 제가 이 부분을 크게 놓치고 있어서, 기본부터 다시 공부했습니다. 소중한 리뷰 정말 감사합니다🔥
src/items/items.service.ts
Outdated
|
||
if (existingItems.length > 0) { | ||
const ownedItemIds = existingItems.map((item) => item.itemId); | ||
throw new BadRequestException( |
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.
보통 이렇게 중복된 리소스에 대한 에러를 반환하는 경우 status code 중 409를 사용합니다.
What Is a 409 Status Code?
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.
네 409상태코드 기억해두겠습니당!
src/items/items.controller.ts
Outdated
@ApiItems.addItem() | ||
async addItem(@Body() addItemDto: ItemChangeStatusDto): Promise<void> { | ||
await this.itemsService.addItem(addItemDto); | ||
} |
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.
아이템 추가시 price 데이터는 넣지 않나요??
그리고 userId 데이터도 ItemChangeStatusDto
에 포함되어 있던데 userId도 사용 되나요 ?
import { ApiPropertyOptional, PartialType } from '@nestjs/swagger'; | ||
import { CreatePartDto } from './create-part.dto'; | ||
import { IsInt, IsString, Min } from 'class-validator'; | ||
|
||
export class UpdatePartDto extends PartialType(CreatePartDto) { | ||
@ApiPropertyOptional({ | ||
description: '상위 섹션 id', | ||
example: 1, | ||
}) | ||
@IsInt() | ||
@Min(0) | ||
readonly sectionId?: number; | ||
|
||
@ApiPropertyOptional({ | ||
description: '파트 이름', | ||
example: 1, | ||
}) | ||
@IsString() | ||
readonly name?: string; | ||
} |
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.
@dg1418 Section과 Part 모듈의 코드들이 있네요?
혹시 잘못들어간건지 같이 봐야겠네요;
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.
네 제가 아직 pull 하지 않아 생긴 문제인 것 같습니다 ㅎ
🔗 관련 이슈
#41
📝작업 내용
이에 필요한 작업은
이었습니다.
🔍 변경 사항
💬리뷰 요구사항 (선택사항)