Skip to content

Feat/#3 product api #7

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

Open
wants to merge 25 commits into
base: feat/#2_Admin_Login
Choose a base branch
from
Open

Conversation

724thomas
Copy link
Collaborator

@724thomas 724thomas commented Apr 18, 2025

PR 유형

이 PR은 어떤 종류의 변경을 가져오나요?

  • 버그 수정
  • 새로운 기능 추가
  • 코드 스타일 업데이트 (서식, 로컬 변수)
  • 리팩터링 (기능 변경 없음, API 변경 없음)
  • 빌드 관련 변경
  • CI 관련 변경
  • 문서 내용 변경
  • 애플리케이션 / 인프라 변경
  • 기타... 설명:

현재 동작은 무엇인가요?

이슈 번호: resolves #6

새로운 동작은 무엇인가요?

  • 제품 이미지 업로드
  • 제품 등록
  • 제품 조회
  • 제품 수정
  • 제품 제거

기타 정보

  • 제품 이미지 업로드
    image
    image

  • 제품 등록
    image
    image

  • 제품들 조회 (/api/v1/products?categoryId=1&minPrice=0&maxPrice=100000)
    image

  • 제품 조회
    image

  • 제품 수정
    image
    image

  • 제품 삭제
    image
    image
    image

@724thomas 724thomas changed the base branch from main to feat/#2_Admin_Login April 18, 2025 11:05
private String[] imageUrls;
private String[] imageKeys;
private Boolean[] isThumbnail;
private int[] imageSortOrder;

Choose a reason for hiding this comment

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

값이 배열에 어떻게 들어가나요?

.orElseThrow(() -> new BadRequestException("Category not found"));
product.setCategory(category);
}
return product.getId();

Choose a reason for hiding this comment

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

이 부분은 저장을 어디서 수행하게 되나요?

Product product = productApiRepository.findById(productId)
.orElseThrow(() -> new BadRequestException("Product not found"));
for (ProductImage image : product.getProductImages()) {
image.setProduct(null);

Choose a reason for hiding this comment

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

굳이 이미지에서 연결된 매핑을 지울 필요는 없을 것 같습니다. 필요하다면 ProductImage 자체를 소프트 딜리트하면 될 것 같습니다

return AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(endpoint, "us-east-1"))
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)))

Choose a reason for hiding this comment

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

아시겠지만 이렇게 사용 안하시는게 좋습니다. 주석 정도 남겨두시면 좋을 것 같습니다.

.from(product)
.where(where)
.fetchOne())
.orElse(0L);

Choose a reason for hiding this comment

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

이건 무슨 쿼리인가요?

))
.from(product)
.leftJoin(product.productImages, thumbnailImage)
.on(thumbnailImage.isThumbnail.eq(true))

Choose a reason for hiding this comment

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

디자인을 좀 바꾸는게 좋을 것 같습니다.

where.and(betweenPrice(conditionDto.getMinPrice(), conditionDto.getMaxPrice()));
where.and(categoryCondition(conditionDto.getCategoryId()));

Pageable pageable = PageRequest.of(conditionDto.getPage(), conditionDto.getSize());

Choose a reason for hiding this comment

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

Paging 쿼리를 파라미터로 받아오는게 여러모로 확장성이 좋습니다. 지금 이 메서드는 웹 기반 서치를 위한 용도로 한정되네요

BooleanBuilder where = new BooleanBuilder();
where.and(isDeleted(false));
where.and(betweenPrice(conditionDto.getMinPrice(), conditionDto.getMaxPrice()));
where.and(categoryCondition(conditionDto.getCategoryId()));

Choose a reason for hiding this comment

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

쿼리 패턴 조금 바꾸면 좋을 것 같습니다 전체적으로요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • join말고 쿼리를 두번 날리는게 낫다. ajax도 많아지고, 반응형. 긁어오는 데이터는 최적이다.

return asc ? product.price.asc() : product.price.desc();
} else {
throw new IllegalArgumentException("Invalid sort field: " + field);
}

Choose a reason for hiding this comment

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

로직은 가급적 서비스로 빼는게 좋습니다. 다른 메서드도 마찬가지입니다

public class ImageUploadDto {
String imageId; // UUID = DB id
String key; // s3 key. 삭제시 사용됨
String url;

Choose a reason for hiding this comment

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

URL 과 Key 의 차이는 뭔가요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat #3: 상품관리
2 participants