Skip to content
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

Feat: 부스 상품 수정 API #265

Merged
merged 13 commits into from
Oct 14, 2024
Merged

Feat: 부스 상품 수정 API #265

merged 13 commits into from
Oct 14, 2024

Conversation

muncool39
Copy link
Member

Summary

부스 상품을 수정하는 API를 개발했습니다.

API
PATCH /booths/products/{product_id}

Requestbody

{
    /* 변경할 값만 포함해서 요청
    "name" : 변경할 상품명
    "description" : 변경할 설명
    "stock" : 변경할 재고 (integer)
    "price" : 변경할 가격 (integer)
    "categoryId" : 변경할 카테고리 id (integer)
    */
}

오류가 발생하는 상황

  • 현재 로그인 된 유저가 해당 부스의 관리자가 아닌 경우
  • 요청 값이 없는 경우
  • 변경할 카테고리 아이디와 일치하는 카테고리가 없거나 해당 부스의 카테고리가 아닌 경우

Key Changes

  • 요청 객체, 업데이트 객체 추가
  • ErrorCode: 카테고리 아이디가 다른 부스의 카테고리인 경우의 에러 코드 추가
  • BoothProductController: 상품 수정 api 컨트롤러 추가
  • BoothProductService: 상품 수정 로직 추가
  • BoothProduct: 업데이트 메서드 추가

Testing

성공

  • 요청 PATCH /booths/products/13
{
    "name" : "사자 인형",
    "description" : "노랑색 사자 인형입니다.",
    "price" : 8000
}
  • 응답
    image

실패 1 (401) 다른 유저의 토큰을 헤더로 요청한 경우

  • 요청 PATCH /booths/products/13
{
    "name" : "사자 인형",
    "description" : "노랑색 사자 인형입니다.",
    "price" : 8000
}

image

실패 2 (409) 다른 부스의 카테고리 아이디를 요청한 경우

  • 요청 PATCH /booths/products/13
{
    "categoryId" : 24
}

image

To Reviewers

  • 궁금한 점이나 개선 방안 등 의견 있으시면 편하게 말씀해주세요! 😃

@muncool39 muncool39 added the feature 기능 개발과 관련된 내용입니다. label Oct 8, 2024
@muncool39 muncool39 requested a review from gitseoyeon October 8, 2024 15:54
@muncool39 muncool39 self-assigned this Oct 8, 2024
Copy link
Member

@gitseoyeon gitseoyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다!
코드 보다가 잠시 생각난건, 혹시 저희 상품명과 관련되어서는 중복 처리 안해도 될까요?! 사실 크게 상관 없어 보이긴 하는데 하게된다면 등록과 수정 과정에서 중복 처리 과정도 필요해 보일 듯합니다!

@muncool39
Copy link
Member Author

앗 해당 처리가 빠져있었네요! 감사합니다 !! 😭 반영하겠습니다 !

@muncool39 muncool39 requested a review from gitseoyeon October 11, 2024 08:06
@muncool39
Copy link
Member Author

추가적으로 부스 상품 이미지를 수정하는 기능을 넣었습니다.

Summary

  • 부스 상품의 이미지를 변경
  • 삭제할 이미지 아이디와 추가할 이미지 파일을 받도록 요청 객체에 추가
  • 두 합이 5를 넘길 경우 오류 메세지 리턴

추가 변경 사항

  • 기존 부스 상품 서비스에 있던 이미지 관련 로직을 상품 이미지 서비스 클래스로 분리했습니다.
  • 기존 부스 상품 서비스에 있던 카테고리 관련 로직을 상품 카테고리 서비스 클래스로 분리했습니다.

To Reviewers

  • 중복 처리 관련해서, 코드에 대해 생각할 점이 많기도 해서 추후 Fix 브런치를 나눠 수정하려고 하는데 괜찮으실까요?

Copy link
Member

@gitseoyeon gitseoyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다!! 브랜치 나눠서 하는 것도 좋은 방법인 것 같습니🙂

@muncool39 muncool39 merged commit 5df2f83 into dev Oct 14, 2024
2 checks passed
@muncool39 muncool39 deleted the feat/#264 branch October 14, 2024 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 기능 개발과 관련된 내용입니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 부스 상품 수정 기능
2 participants