-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: feat/#2_Admin_Login
Are you sure you want to change the base?
Conversation
private String[] imageUrls; | ||
private String[] imageKeys; | ||
private Boolean[] isThumbnail; | ||
private int[] imageSortOrder; |
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.
값이 배열에 어떻게 들어가나요?
.orElseThrow(() -> new BadRequestException("Category not found")); | ||
product.setCategory(category); | ||
} | ||
return product.getId(); |
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.
이 부분은 저장을 어디서 수행하게 되나요?
Product product = productApiRepository.findById(productId) | ||
.orElseThrow(() -> new BadRequestException("Product not found")); | ||
for (ProductImage image : product.getProductImages()) { | ||
image.setProduct(null); |
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.
굳이 이미지에서 연결된 매핑을 지울 필요는 없을 것 같습니다. 필요하다면 ProductImage 자체를 소프트 딜리트하면 될 것 같습니다
return AmazonS3ClientBuilder.standard() | ||
.withEndpointConfiguration( | ||
new AwsClientBuilder.EndpointConfiguration(endpoint, "us-east-1")) | ||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))) |
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.
아시겠지만 이렇게 사용 안하시는게 좋습니다. 주석 정도 남겨두시면 좋을 것 같습니다.
.from(product) | ||
.where(where) | ||
.fetchOne()) | ||
.orElse(0L); |
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.
이건 무슨 쿼리인가요?
)) | ||
.from(product) | ||
.leftJoin(product.productImages, thumbnailImage) | ||
.on(thumbnailImage.isThumbnail.eq(true)) |
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.
디자인을 좀 바꾸는게 좋을 것 같습니다.
where.and(betweenPrice(conditionDto.getMinPrice(), conditionDto.getMaxPrice())); | ||
where.and(categoryCondition(conditionDto.getCategoryId())); | ||
|
||
Pageable pageable = PageRequest.of(conditionDto.getPage(), conditionDto.getSize()); |
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.
Paging 쿼리를 파라미터로 받아오는게 여러모로 확장성이 좋습니다. 지금 이 메서드는 웹 기반 서치를 위한 용도로 한정되네요
BooleanBuilder where = new BooleanBuilder(); | ||
where.and(isDeleted(false)); | ||
where.and(betweenPrice(conditionDto.getMinPrice(), conditionDto.getMaxPrice())); | ||
where.and(categoryCondition(conditionDto.getCategoryId())); |
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.
쿼리 패턴 조금 바꾸면 좋을 것 같습니다 전체적으로요
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.
- join말고 쿼리를 두번 날리는게 낫다. ajax도 많아지고, 반응형. 긁어오는 데이터는 최적이다.
return asc ? product.price.asc() : product.price.desc(); | ||
} else { | ||
throw new IllegalArgumentException("Invalid sort field: " + field); | ||
} |
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.
로직은 가급적 서비스로 빼는게 좋습니다. 다른 메서드도 마찬가지입니다
public class ImageUploadDto { | ||
String imageId; // UUID = DB id | ||
String key; // s3 key. 삭제시 사용됨 | ||
String url; |
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.
URL 과 Key 의 차이는 뭔가요?
PR 유형
이 PR은 어떤 종류의 변경을 가져오나요?
현재 동작은 무엇인가요?
이슈 번호: resolves #6
새로운 동작은 무엇인가요?
기타 정보
제품 이미지 업로드


제품 등록


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

제품 조회

제품 수정


제품 삭제


