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

상품 판매 등록 기능 구현 #10

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

11dlguswns
Copy link
Contributor

💡 개요
상품 판매 등록 기능을 구현했습니다.

📃 작업내용

  • 상품 판매 등록
  • 이미지 저장
  • 태그 저장

🔀 변경사항

  • Product Entity의 price 필드 자료형 수정

@11dlguswns 11dlguswns linked an issue Oct 24, 2024 that may be closed by this pull request
@Size(max = 3, message = "이미지는 최대 3장까지 입니다.") @RequestPart("images") List<MultipartFile> images
) {
productService.createProduct(request, images);
return ResponseEntity.ok().build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

작성이 완료되었다는거니까 OK 대신에 created는 어떤가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ea7fc42
수정했습니다.


@Getter
@AllArgsConstructor
public class CreateProductReq {
Copy link
Collaborator

Choose a reason for hiding this comment

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

record 클래스로 변경해주시면 좋을거같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

60f49b0
수정했습니다

import com.mango.amango.domain.product.entity.Product;
import org.springframework.data.repository.CrudRepository;

public interface ProductRepository extends CrudRepository<Product, Long> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

CrudRepository를 상속받으신 이유가 있나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

4a6021f
spring data의 save 기능만을 생각하고 상속받았었는데 보고나니 Product는 나중에 기능을 추가하다보면 JPARepository가 필요할 것 같아서 수정 했습니다.

@Service
@Transactional
@RequiredArgsConstructor
public class ProductService {
Copy link
Collaborator

Choose a reason for hiding this comment

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

다른 서비스 파일들과 같게 Impl 파일을 사용하는 형식으로 바꾸면 좋을거같아요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

auth 서비스는 로그인 방식이 바뀔 상황을 생각해서 전략 패턴으로 구현했는데 product 서비스 부분도 이와 같은 방법으로 구현하는게 좋을지 궁금합니다

Copy link
Collaborator

Choose a reason for hiding this comment

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

인터페이스와 구현체를 분리하여 구현체를 독립적으로 확장할 수 있으며, 구현체 클래스를 변경하거나 확장해도 이를 사용하는 클라이언트의 코드에 영향을 주지 않습니다
이와 같이 구현을 하게 되면 객체지향의 5원칙중 OCP 원칙을 가장 잘 실행해주는 방법입니다.
또한 관습적으로 많이 사용하는 방법이기도 합니다!

@11dlguswns 11dlguswns self-assigned this Oct 24, 2024
@11dlguswns 11dlguswns added the ✨Feature New feature or request label Oct 24, 2024
Copy link
Collaborator

@ta2ye0n ta2ye0n left a comment

Choose a reason for hiding this comment

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

Security Config에 endpoint 추가가 안된거같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

상품 판매 등록 기능 구현
2 participants