Skip to content

Commit

Permalink
Merge pull request #286 from linglong67/feature/review-file-upload
Browse files Browse the repository at this point in the history
[feat] 리뷰 API 수정 (이전 PR 내 이슈 수정)
  • Loading branch information
linglong67 authored Mar 12, 2024
2 parents 1b9f2a6 + 743c8c8 commit 5371c27
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void updateReview(ReviewRequestDto reviewRequestDto, List<MultipartFile>
reviewRepository.saveAndFlush(reviewRequestDto.toEntityForUpdate());
log.info("리뷰 수정 -> review_no {}", reviewRequestDto.reviewNo());

fileRepository.findByReferenceNo(reviewRequestDto.reviewNo())
fileRepository.findByReferenceTypeAndReferenceNo(REVIEW_CODE, reviewRequestDto.reviewNo())
.stream()
.forEach(file -> {
if (!reviewRequestDto.files().contains(file.getFileUrl())) {
Expand All @@ -138,13 +138,13 @@ public void deleteReview(Long reviewNo) {
reviewRepository.deleteById(reviewNo);
log.info("리뷰 삭제 -> review_no {}", reviewNo);

fileRepository.findByReferenceNo(reviewNo)
fileRepository.findByReferenceTypeAndReferenceNo(REVIEW_CODE, reviewNo)
.stream()
.forEach(file -> {
fileUtils.delete(file.getFileKey());
log.info("리뷰 파일 삭제 -> file_no {}", file.getFileNo());
});
fileRepository.deleteByReferenceNo(reviewNo);
fileRepository.deleteByReferenceTypeAndReferenceNo(REVIEW_CODE, reviewNo);
}

private Review isVisibleReview(Long reviewNo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class File extends BaseEntity {
@Column(name = "reference_no", nullable = false)
private Long referenceNo;

public File(Long fileNo, String fileName, String fileKey, String fileUrl, String referenceType, Long referenceNo) {
private File(Long fileNo, String fileName, String fileKey, String fileUrl, String referenceType, Long referenceNo) {
this.fileNo = fileNo;
this.fileName = fileName;
this.fileKey = fileKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

public interface FileRepositoryJpa extends JpaRepository<File, Long> {
List<File> findByReferenceNo(Long referenceNo);
List<File> findByReferenceTypeAndReferenceNo(String referenceType, Long referenceNo);

void deleteByReferenceNo(Long referenceNo);
void deleteByReferenceTypeAndReferenceNo(String referenceType, Long referenceNo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ public void updateFromInfo(int gender, int age) {
this.age = age;
}

/**
* review request
**/
private Member (Long memberNo) {
this.memberNo = memberNo;
}

/**
* review request
**/
public static Member of(Long memberNo) {
return new Member(memberNo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ private Product(
this.violationInfo = violationInfo;
}

/**
* review request
**/
private Product(Long productNo) {
this.productNo = productNo;
}
Expand Down Expand Up @@ -210,6 +213,9 @@ public static Product of(String productName,
fluorescentWhitening, manufactureType, manufactureMethod, manufactureNation, violation_info);
}

/**
* review request
**/
public static Product of(Long productNo) {
return new Product(productNo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private Review(Long reviewNo, Product product, Member member, BigDecimal starRat
this.isVisible = isVisible;
}

public Review(Long reviewNo, BigDecimal starRating, String title, String contents, Boolean isVisible) {
private Review(Long reviewNo, BigDecimal starRating, String title, String contents, Boolean isVisible) {
this.reviewNo = reviewNo;
this.starRating = starRating;
this.title = title;
Expand Down

0 comments on commit 5371c27

Please sign in to comment.