From 146fbfea8fa2416dd1fea02dfa110492355ba42b Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 09:59:52 +0900 Subject: [PATCH 01/10] rebase --- .../api/inquiry/InquiryController.java | 51 +++++++++++++++++++ .../example/api/review/ReviewRepository.java | 1 + .../com/example/api/review/ReviewService.java | 1 - .../review/controller/ReviewController.java | 7 ++- .../example/api/review/dto/ReviewCommand.java | 2 + .../example/api/review/dto/ReviewRequest.java | 2 + .../api/inquiry/InquiryControllerTest.java | 2 + .../api/inquiry/InquiryServiceTest.java | 4 ++ 8 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/example/api/inquiry/InquiryController.java create mode 100644 src/main/java/com/example/api/review/dto/ReviewCommand.java create mode 100644 src/main/java/com/example/api/review/dto/ReviewRequest.java create mode 100644 src/test/java/com/example/api/inquiry/InquiryControllerTest.java diff --git a/src/main/java/com/example/api/inquiry/InquiryController.java b/src/main/java/com/example/api/inquiry/InquiryController.java new file mode 100644 index 00000000..0967f0e1 --- /dev/null +++ b/src/main/java/com/example/api/inquiry/InquiryController.java @@ -0,0 +1,51 @@ +package com.example.api.inquiry.controller; + +import com.example.api.domain.Account; +import com.example.api.domain.Inquiry; +import com.example.api.inquiry.InquiryService; +import com.example.api.inquiry.dto.InquiryRequest; +import com.example.api.inquiry.dto.InquiryResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/support") +public class InquiryController { + private final InquiryService inquiryService; + + @PostMapping("/inquiry") + public ResponseEntity createInquiry( + @RequestBody final InquiryRequest inquiryRequest + ) { + final Inquiry inquiry = inquiryService.saveInquiry( + inquiryRequest, + inquiryRequest.createdBy() + ); + final InquiryResponse inquiryResponse = mapToResponse(inquiry); + return ResponseEntity.ok(inquiryResponse); + } + + @GetMapping("/my-inquiries") + public ResponseEntity> getMyInquiries( + @RequestParam(required = true) final Long accountId + ) { + final List inquiryResponses = inquiryService.getInquiriesByAccountId(accountId); + return ResponseEntity.ok(inquiryResponses); + } + + private InquiryResponse mapToResponse(Inquiry inquiry) { + return new InquiryResponse( + inquiry.getInquiryId(), + inquiry.getInquiryType(), + inquiry.getSubInquiryType(), + inquiry.getTitle(), + inquiry.getContent(), + inquiry.getInquiryStatus().name(), + inquiry.getAnswerDate(), + inquiry.getCreatedBy() + ); + } +} diff --git a/src/main/java/com/example/api/review/ReviewRepository.java b/src/main/java/com/example/api/review/ReviewRepository.java index 85331d69..0fe1f99d 100644 --- a/src/main/java/com/example/api/review/ReviewRepository.java +++ b/src/main/java/com/example/api/review/ReviewRepository.java @@ -15,4 +15,5 @@ public interface ReviewRepository extends JpaRepository { @Query("SELECT r FROM Review r WHERE (:reviewId IS NULL OR r.reviewId = :reviewId)") List findReviewsByDynamicQuery(@Param("reviewId") Long reviewId); + } diff --git a/src/main/java/com/example/api/review/ReviewService.java b/src/main/java/com/example/api/review/ReviewService.java index da731d05..208ba80c 100644 --- a/src/main/java/com/example/api/review/ReviewService.java +++ b/src/main/java/com/example/api/review/ReviewService.java @@ -32,4 +32,3 @@ public List getReviewsByEmployee( .toList(); } } - diff --git a/src/main/java/com/example/api/review/controller/ReviewController.java b/src/main/java/com/example/api/review/controller/ReviewController.java index dba6f492..048e1154 100644 --- a/src/main/java/com/example/api/review/controller/ReviewController.java +++ b/src/main/java/com/example/api/review/controller/ReviewController.java @@ -1,3 +1,4 @@ +<<<<<<< HEAD package com.example.api.review.controller; import com.example.api.review.ReviewService; @@ -27,4 +28,8 @@ public ResponseEntity> getReviewsByEmployee( final List reviews = reviewService.getReviewsByEmployee(reivewId); return ResponseEntity.ok(reviews); } -} \ No newline at end of file +} +======= +package com.example.api.review.controller;public class ReviewController { +} +>>>>>>> 2f6b5cc (#53 feat(ReviewCommand): DTO 작성) diff --git a/src/main/java/com/example/api/review/dto/ReviewCommand.java b/src/main/java/com/example/api/review/dto/ReviewCommand.java new file mode 100644 index 00000000..46f98d82 --- /dev/null +++ b/src/main/java/com/example/api/review/dto/ReviewCommand.java @@ -0,0 +1,2 @@ +package com.example.api.review.dto;public record ReviewCommand() { +} diff --git a/src/main/java/com/example/api/review/dto/ReviewRequest.java b/src/main/java/com/example/api/review/dto/ReviewRequest.java new file mode 100644 index 00000000..29a4f219 --- /dev/null +++ b/src/main/java/com/example/api/review/dto/ReviewRequest.java @@ -0,0 +1,2 @@ +package com.example.api.review.dto;public record ReviewRequest() { +} diff --git a/src/test/java/com/example/api/inquiry/InquiryControllerTest.java b/src/test/java/com/example/api/inquiry/InquiryControllerTest.java new file mode 100644 index 00000000..16301095 --- /dev/null +++ b/src/test/java/com/example/api/inquiry/InquiryControllerTest.java @@ -0,0 +1,2 @@ +package com.example.api.inquiry;public class InquiryControllerTest { +} diff --git a/src/test/java/com/example/api/inquiry/InquiryServiceTest.java b/src/test/java/com/example/api/inquiry/InquiryServiceTest.java index 5fada952..b547b264 100644 --- a/src/test/java/com/example/api/inquiry/InquiryServiceTest.java +++ b/src/test/java/com/example/api/inquiry/InquiryServiceTest.java @@ -1,5 +1,6 @@ package com.example.api.inquiry; +<<<<<<< HEAD import com.example.api.account.repository.AccountRepository; import com.example.api.domain.Account; import com.example.api.domain.Inquiry; @@ -111,4 +112,7 @@ void mapToInquiry_shouldMapCommandToInquiry() { assertThat(inquiry).isNotNull(); assertThat(inquiry.getTitle()).isEqualTo("Test Title"); } +======= +public class InquiryServiceController { +>>>>>>> 2f6b5cc (#53 feat(ReviewCommand): DTO 작성) } From 6bc622226027bd222ca33c69ebcb8ce2cf61dae4 Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 10:03:18 +0900 Subject: [PATCH 02/10] rebase --- .../java/com/example/api/domain/Review.java | 3 +- .../api/inquiry/InquiryController.java | 2 +- .../example/api/review/ReviewRepository.java | 21 ++++++ .../com/example/api/review/ReviewService.java | 50 ++++++++++++- .../review/controller/ReviewController.java | 6 ++ .../example/api/review/dto/ReviewCommand.java | 11 ++- .../example/api/review/dto/ReviewRequest.java | 6 +- .../api/review/dto/ReviewResponse.java | 16 +++++ .../api/inquiry/InquiryControllerTest.java | 72 ++++++++++++++++++- .../api/inquiry/InquiryServiceTest.java | 4 ++ 10 files changed, 184 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/example/api/domain/Review.java b/src/main/java/com/example/api/domain/Review.java index d8294804..1ff66018 100644 --- a/src/main/java/com/example/api/domain/Review.java +++ b/src/main/java/com/example/api/domain/Review.java @@ -8,8 +8,8 @@ @Entity @Getter @Table(name = "REVIEW") -@EqualsAndHashCode(callSuper = true) @NoArgsConstructor +@EqualsAndHashCode(callSuper = true) public class Review extends BaseEntity { @Id @Column(name ="REVIEW_ID") @@ -37,7 +37,6 @@ public class Review extends BaseEntity { @Column(name = "REVIEW_CONTENT") private String reviewContent; - public Review(int reviewStarPoint, String reviewContent, Contract contract) { this.reviewStarPoint = reviewStarPoint; this.reviewContent = reviewContent; diff --git a/src/main/java/com/example/api/inquiry/InquiryController.java b/src/main/java/com/example/api/inquiry/InquiryController.java index 0967f0e1..afc0c4a9 100644 --- a/src/main/java/com/example/api/inquiry/InquiryController.java +++ b/src/main/java/com/example/api/inquiry/InquiryController.java @@ -1,4 +1,4 @@ -package com.example.api.inquiry.controller; +package com.example.api.inquiry; import com.example.api.domain.Account; import com.example.api.domain.Inquiry; diff --git a/src/main/java/com/example/api/review/ReviewRepository.java b/src/main/java/com/example/api/review/ReviewRepository.java index 0fe1f99d..38072f2f 100644 --- a/src/main/java/com/example/api/review/ReviewRepository.java +++ b/src/main/java/com/example/api/review/ReviewRepository.java @@ -1,6 +1,7 @@ package com.example.api.review; import com.example.api.domain.Review; +<<<<<<< HEAD import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -16,4 +17,24 @@ public interface ReviewRepository extends JpaRepository { @Query("SELECT r FROM Review r WHERE (:reviewId IS NULL OR r.reviewId = :reviewId)") List findReviewsByDynamicQuery(@Param("reviewId") Long reviewId); +======= +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import java.util.List; + +public interface ReviewRepository extends JpaRepository { + List findReviewsByAccountId(final Long accountId); + Page findReviewsByAccountId(final Long accountId, final Pageable pageable); + + @Query("SELECT r FROM Review r " + + "JOIN FETCH r.business b " + + "JOIN FETCH r.account a " + + "JOIN FETCH r.contract c " + + "WHERE a.accountId = :accountId") + List findReviewsByAccountIdWithDetails(final Long accountId); +>>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) } + + diff --git a/src/main/java/com/example/api/review/ReviewService.java b/src/main/java/com/example/api/review/ReviewService.java index 208ba80c..49548a92 100644 --- a/src/main/java/com/example/api/review/ReviewService.java +++ b/src/main/java/com/example/api/review/ReviewService.java @@ -8,6 +8,19 @@ import java.util.List; +import com.example.api.domain.Review; +import com.example.api.review.dto.*; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + @Service @RequiredArgsConstructor public class ReviewService { @@ -30,5 +43,40 @@ public List getReviewsByEmployee( .stream() .map(ReviewResponse::from) .toList(); + + public List getReviewsByEmployee ( @Validated final ReviewCommand reviewCommand){ + final List reviews = reviewRepository.findReviewsByAccountId(reviewCommand.accountId()); + return reviews.stream() + .map(this::mapToReviewResponse) + .collect(Collectors.toList()); + } + + @Transactional + public Page getReviewsByEmployeeWithPagination ( + @Validated final ReviewCommand reviewCommand, + final Pageable pageable + ){ + final Page reviewsPage = reviewRepository.findReviewsByAccountId( + reviewCommand.accountId(), + pageable); + return reviewsPage.map(this::mapToReviewResponse); + } + + @Transactional + public List getReviewsByEmployeeWithDetails ( @Validated final ReviewCommand reviewCommand){ + final List reviews = reviewRepository.findReviewsByAccountIdWithDetails(reviewCommand.accountId()); + return reviews.stream() + .map(this::mapToReviewResponse) + .collect(Collectors.toList()); + } + + private ReviewResponse mapToReviewResponse ( final Review review){ + final String businessName = review.getBusiness().getBusinessName(); + final Long businessId = review.getBusiness().getBusinessId(); + final LocalDateTime contractSrartTime = review.getContract().getContractStartTime(); + final LocalDateTime contractEndTime = review.getContract().getContractEndTime(); + final int reviewStarPoint = review.getReviewStarPoint(); + final String reviewContent = review.getReviewContent(); + return new ReviewResponse(businessName, businessId, contractSrartTime, contractEndTime, reviewStarPoint, reviewContent); + } } -} diff --git a/src/main/java/com/example/api/review/controller/ReviewController.java b/src/main/java/com/example/api/review/controller/ReviewController.java index 048e1154..955b1f42 100644 --- a/src/main/java/com/example/api/review/controller/ReviewController.java +++ b/src/main/java/com/example/api/review/controller/ReviewController.java @@ -1,4 +1,5 @@ <<<<<<< HEAD +<<<<<<< HEAD package com.example.api.review.controller; import com.example.api.review.ReviewService; @@ -31,5 +32,10 @@ public ResponseEntity> getReviewsByEmployee( } ======= package com.example.api.review.controller;public class ReviewController { +======= +package com.example.api.review.controller; + +public class ReviewController { +>>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) } >>>>>>> 2f6b5cc (#53 feat(ReviewCommand): DTO 작성) diff --git a/src/main/java/com/example/api/review/dto/ReviewCommand.java b/src/main/java/com/example/api/review/dto/ReviewCommand.java index 46f98d82..e12c26b1 100644 --- a/src/main/java/com/example/api/review/dto/ReviewCommand.java +++ b/src/main/java/com/example/api/review/dto/ReviewCommand.java @@ -1,2 +1,11 @@ -package com.example.api.review.dto;public record ReviewCommand() { +package com.example.api.review.dto; + +public record ReviewCommand( + Long reviewId, + int reviewStarPoint, + String reviewContent, + Long accountId, + Long businessId, + Long contractId) { } + diff --git a/src/main/java/com/example/api/review/dto/ReviewRequest.java b/src/main/java/com/example/api/review/dto/ReviewRequest.java index 29a4f219..ce7e4c07 100644 --- a/src/main/java/com/example/api/review/dto/ReviewRequest.java +++ b/src/main/java/com/example/api/review/dto/ReviewRequest.java @@ -1,2 +1,6 @@ -package com.example.api.review.dto;public record ReviewRequest() { +package com.example.api.review.dto; + +public record ReviewRequest( + Long accountId +) { } diff --git a/src/main/java/com/example/api/review/dto/ReviewResponse.java b/src/main/java/com/example/api/review/dto/ReviewResponse.java index 9a02b3b0..dad3afa4 100644 --- a/src/main/java/com/example/api/review/dto/ReviewResponse.java +++ b/src/main/java/com/example/api/review/dto/ReviewResponse.java @@ -1,5 +1,6 @@ package com.example.api.review.dto; +<<<<<<< HEAD import com.example.api.domain.Account; import com.example.api.domain.Business; import com.example.api.domain.Review; @@ -23,3 +24,18 @@ public static ReviewResponse from(Review review) { } } +======= +import java.time.LocalDate; +import java.time.LocalDateTime; + +public record ReviewResponse( + String businessName, + Long businessId, + LocalDateTime contractSrartTime, + LocalDateTime contractEndTime, + int reviewStarPoint, + String reviewContent) { +} + + +>>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) diff --git a/src/test/java/com/example/api/inquiry/InquiryControllerTest.java b/src/test/java/com/example/api/inquiry/InquiryControllerTest.java index 16301095..e2358e47 100644 --- a/src/test/java/com/example/api/inquiry/InquiryControllerTest.java +++ b/src/test/java/com/example/api/inquiry/InquiryControllerTest.java @@ -1,2 +1,72 @@ -package com.example.api.inquiry;public class InquiryControllerTest { +package com.example.api.inquiry; + +import com.example.api.domain.Account; +import com.example.api.domain.Inquiry; +import com.example.api.global.BaseIntegrationTest; +import com.example.api.inquiry.dto.InquiryResponse; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import java.util.List; + +class InquiryControllerTest extends BaseIntegrationTest { + @Autowired + private InquiryController inquiryController; + + @Test + void getMyInquiries() { + Account account = new Account(); + account.setAccountId(1L); + Inquiry inquiry1 = new Inquiry(); + inquiry1.setInquiryId(1L); + inquiry1.setInquiryType("General"); + inquiry1.setTitle("Test Inquiry 1"); + inquiry1.setCreatedBy(account); + + Inquiry inquiry2 = new Inquiry(); + inquiry2.setInquiryId(2L); + inquiry2.setInquiryType("Support"); + inquiry2.setTitle("Test Inquiry 2"); + inquiry2.setCreatedBy(account); + + List expectedResponses = List.of( + new InquiryResponse( + inquiry1.getInquiryId(), + inquiry1.getInquiryType(), + inquiry1.getSubInquiryType(), + inquiry1.getTitle(), + inquiry1.getContent(), + inquiry1.getInquiryStatus().name(), + inquiry1.getAnswerDate(), + inquiry1.getCreatedBy() + ), + new InquiryResponse( + inquiry2.getInquiryId(), + inquiry2.getInquiryType(), + inquiry2.getSubInquiryType(), + inquiry2.getTitle(), + inquiry2.getContent(), + inquiry2.getInquiryStatus().name(), + inquiry2.getAnswerDate(), + inquiry2.getCreatedBy() + ) + ); + + ResponseEntity> response = inquiryController.getMyInquiries(1L); + + Assertions.assertNotNull(response); + Assertions.assertEquals(HttpStatus.OK, response.getStatusCode()); + List actualResponses = response.getBody(); + Assertions.assertNotNull(actualResponses); + Assertions.assertEquals(expectedResponses.size(), actualResponses.size()); + + for (int i = 0; i < expectedResponses.size(); i++) { + Assertions.assertEquals(expectedResponses.get(i).getInquiryId(), actualResponses.get(i).getInquiryId()); + Assertions.assertEquals(expectedResponses.get(i).getInquiryType(), actualResponses.get(i).getInquiryType()); + Assertions.assertEquals(expectedResponses.get(i).getTitle(), actualResponses.get(i).getTitle()); + } + } } diff --git a/src/test/java/com/example/api/inquiry/InquiryServiceTest.java b/src/test/java/com/example/api/inquiry/InquiryServiceTest.java index b547b264..7b722a77 100644 --- a/src/test/java/com/example/api/inquiry/InquiryServiceTest.java +++ b/src/test/java/com/example/api/inquiry/InquiryServiceTest.java @@ -1,5 +1,6 @@ package com.example.api.inquiry; +<<<<<<< HEAD <<<<<<< HEAD import com.example.api.account.repository.AccountRepository; import com.example.api.domain.Account; @@ -115,4 +116,7 @@ void mapToInquiry_shouldMapCommandToInquiry() { ======= public class InquiryServiceController { >>>>>>> 2f6b5cc (#53 feat(ReviewCommand): DTO 작성) +======= +public class InquiryServiceTest { +>>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) } From ce0b702bc353e824f66b60ca2b2cba65b789912e Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 10:30:36 +0900 Subject: [PATCH 03/10] rebase --- .../example/api/review/ReviewRepository.java | 32 ++++---- .../com/example/api/review/ReviewService.java | 78 ++++++++----------- .../review/controller/ReviewController.java | 26 +++++++ .../example/api/review/dto/ReviewCommand.java | 16 +++- .../example/api/review/dto/ReviewRequest.java | 6 -- .../api/review/dto/ReviewResponse.java | 32 +++----- 6 files changed, 94 insertions(+), 96 deletions(-) delete mode 100644 src/main/java/com/example/api/review/dto/ReviewRequest.java diff --git a/src/main/java/com/example/api/review/ReviewRepository.java b/src/main/java/com/example/api/review/ReviewRepository.java index 38072f2f..07776345 100644 --- a/src/main/java/com/example/api/review/ReviewRepository.java +++ b/src/main/java/com/example/api/review/ReviewRepository.java @@ -1,40 +1,34 @@ package com.example.api.review; import com.example.api.domain.Review; -<<<<<<< HEAD -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface ReviewRepository extends JpaRepository { - @Query("SELECT r FROM Review r JOIN FETCH r.contract WHERE r.contract.offerEmployment.business.employer.accountId = :employerId") + @Query("SELECT r FROM Review r " + + "JOIN FETCH r.contract c " + + "WHERE c.offerEmployment.business.businessId = :employerId") List loadReviewsByEmployerId(@Param("employerId") Long employerId); - @Query("SELECT r FROM Review r WHERE (:reviewId IS NULL OR r.reviewId = :reviewId)") + @Query("SELECT r FROM Review r " + + "WHERE (:reviewId IS NULL OR r.reviewId = :reviewId)") List findReviewsByDynamicQuery(@Param("reviewId") Long reviewId); -======= -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import java.util.List; - -public interface ReviewRepository extends JpaRepository { - List findReviewsByAccountId(final Long accountId); - Page findReviewsByAccountId(final Long accountId, final Pageable pageable); - @Query("SELECT r FROM Review r " + - "JOIN FETCH r.business b " + - "JOIN FETCH r.account a " + + "JOIN FETCH r.writer b " + + "JOIN FETCH r.employee a " + "JOIN FETCH r.contract c " + "WHERE a.accountId = :accountId") - List findReviewsByAccountIdWithDetails(final Long accountId); ->>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) + List findReviewsByAccountIdWithDetails(@Param("accountId") Long accountId); + + List findReviewsByEmployee_AccountId(Long accountId); } + diff --git a/src/main/java/com/example/api/review/ReviewService.java b/src/main/java/com/example/api/review/ReviewService.java index 49548a92..bf807c77 100644 --- a/src/main/java/com/example/api/review/ReviewService.java +++ b/src/main/java/com/example/api/review/ReviewService.java @@ -10,16 +10,8 @@ import com.example.api.domain.Review; import com.example.api.review.dto.*; -import jakarta.transaction.Transactional; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -34,49 +26,47 @@ public List getAllReviews() { .toList(); } - @Transactional - public List getReviewsByEmployee( - @Validated final Long reviewId - ) { + public List getReviewsByEmployee(@Validated final Long reviewId) { return reviewRepository.findReviewsByDynamicQuery(reviewId) .stream() .map(ReviewResponse::from) .toList(); + } - public List getReviewsByEmployee ( @Validated final ReviewCommand reviewCommand){ - final List reviews = reviewRepository.findReviewsByAccountId(reviewCommand.accountId()); - return reviews.stream() - .map(this::mapToReviewResponse) - .collect(Collectors.toList()); - } + @Transactional + public List getReviews(@Validated final ReviewCommand reviewCommand) { + List reviews = reviewRepository.findReviewsByEmployee_AccountId(reviewCommand.accountId()); + return mapToReviewResponses(reviews); + } - @Transactional - public Page getReviewsByEmployeeWithPagination ( - @Validated final ReviewCommand reviewCommand, - final Pageable pageable - ){ - final Page reviewsPage = reviewRepository.findReviewsByAccountId( - reviewCommand.accountId(), - pageable); - return reviewsPage.map(this::mapToReviewResponse); - } + @Transactional + public List getReviewsByEmployeeWithDetails(@Validated final ReviewCommand reviewCommand) { + final List reviews = reviewRepository.findReviewsByAccountIdWithDetails(reviewCommand.accountId()); + return mapToReviewResponses(reviews); + } - @Transactional - public List getReviewsByEmployeeWithDetails ( @Validated final ReviewCommand reviewCommand){ - final List reviews = reviewRepository.findReviewsByAccountIdWithDetails(reviewCommand.accountId()); - return reviews.stream() - .map(this::mapToReviewResponse) - .collect(Collectors.toList()); - } + private List mapToReviewResponses(final List reviews) { + return reviews.stream() + .map(this::mapToReviewResponse) + .toList(); + } - private ReviewResponse mapToReviewResponse ( final Review review){ - final String businessName = review.getBusiness().getBusinessName(); - final Long businessId = review.getBusiness().getBusinessId(); - final LocalDateTime contractSrartTime = review.getContract().getContractStartTime(); - final LocalDateTime contractEndTime = review.getContract().getContractEndTime(); - final int reviewStarPoint = review.getReviewStarPoint(); - final String reviewContent = review.getReviewContent(); - return new ReviewResponse(businessName, businessId, contractSrartTime, contractEndTime, reviewStarPoint, reviewContent); - } + private ReviewResponse mapToReviewResponse(final Review review) { + final String businessName = review.getContract().getOfferEmployment().getBusiness().getBusinessName(); + final Long businessId = review.getContract().getOfferEmployment().getBusiness().getBusinessId(); + final LocalDateTime contractStartTime = review.getContract().getContractStartTime(); + final LocalDateTime contractEndTime = review.getContract().getContractEndTime(); + final int reviewStarPoint = review.getReviewStarPoint(); + final String reviewContent = review.getReviewContent(); + return new ReviewResponse( + review.getReviewId(), + businessName, + businessId, + contractStartTime, + contractEndTime, + reviewStarPoint, + reviewContent + ); } +} diff --git a/src/main/java/com/example/api/review/controller/ReviewController.java b/src/main/java/com/example/api/review/controller/ReviewController.java index 955b1f42..f3f65911 100644 --- a/src/main/java/com/example/api/review/controller/ReviewController.java +++ b/src/main/java/com/example/api/review/controller/ReviewController.java @@ -35,7 +35,33 @@ public ResponseEntity> getReviewsByEmployee( ======= package com.example.api.review.controller; +import com.example.api.review.ReviewService; +import com.example.api.review.dto.ReviewCommand; +import com.example.api.review.dto.ReviewResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/api/v1/info") +@RequiredArgsConstructor public class ReviewController { +<<<<<<< HEAD >>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) } >>>>>>> 2f6b5cc (#53 feat(ReviewCommand): DTO 작성) +======= + private final ReviewService reviewService; + + @GetMapping("/my/reviews") + public ResponseEntity> getMyReviews( + @RequestParam final Long accountId + ) { + final ReviewCommand reviewCommand = new ReviewCommand(accountId); + final List reviews = reviewService.getReviews(reviewCommand); + return ResponseEntity.ok(reviews); + } +} +>>>>>>> 27670a3 (#53 feat(ReviewController): 컨트롤러 코드 구현) diff --git a/src/main/java/com/example/api/review/dto/ReviewCommand.java b/src/main/java/com/example/api/review/dto/ReviewCommand.java index e12c26b1..0a657404 100644 --- a/src/main/java/com/example/api/review/dto/ReviewCommand.java +++ b/src/main/java/com/example/api/review/dto/ReviewCommand.java @@ -1,11 +1,19 @@ package com.example.api.review.dto; +import java.time.LocalDateTime; + public record ReviewCommand( - Long reviewId, - int reviewStarPoint, - String reviewContent, Long accountId, + String businessName, Long businessId, - Long contractId) { + LocalDateTime contractSrartTime, + LocalDateTime contractEndTime, + int reviewStarPoint, + String reviewContent) { + + public ReviewCommand(Long accountId) { + this(accountId, null, null, null, null, 0, null); + } } + diff --git a/src/main/java/com/example/api/review/dto/ReviewRequest.java b/src/main/java/com/example/api/review/dto/ReviewRequest.java deleted file mode 100644 index ce7e4c07..00000000 --- a/src/main/java/com/example/api/review/dto/ReviewRequest.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.api.review.dto; - -public record ReviewRequest( - Long accountId -) { -} diff --git a/src/main/java/com/example/api/review/dto/ReviewResponse.java b/src/main/java/com/example/api/review/dto/ReviewResponse.java index dad3afa4..a44bbcc2 100644 --- a/src/main/java/com/example/api/review/dto/ReviewResponse.java +++ b/src/main/java/com/example/api/review/dto/ReviewResponse.java @@ -1,41 +1,27 @@ package com.example.api.review.dto; -<<<<<<< HEAD -import com.example.api.domain.Account; -import com.example.api.domain.Business; import com.example.api.domain.Review; +import java.time.LocalDateTime; public record ReviewResponse( Long reviewId, - Business writer, - Account employee, + String businessName, + Long businessId, + LocalDateTime contractStartTime, + LocalDateTime contractEndTime, int reviewStarPoint, String reviewContent - ) { public static ReviewResponse from(Review review) { return new ReviewResponse( review.getReviewId(), - review.getWriter(), - review.getEmployee(), + review.getContract().getOfferEmployment().getBusiness().getBusinessName(), + review.getContract().getOfferEmployment().getBusiness().getBusinessId(), + review.getContract().getContractStartTime(), + review.getContract().getContractEndTime(), review.getReviewStarPoint(), review.getReviewContent() ); } } -======= -import java.time.LocalDate; -import java.time.LocalDateTime; - -public record ReviewResponse( - String businessName, - Long businessId, - LocalDateTime contractSrartTime, - LocalDateTime contractEndTime, - int reviewStarPoint, - String reviewContent) { -} - - ->>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) From e8f9ce999f66860cd7abb9db4e9c0cf007138610 Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 10:35:15 +0900 Subject: [PATCH 04/10] rebase --- .../api/inquiry/InquiryController.java | 51 ------------- .../api/inquiry/InquiryControllerTest.java | 72 ------------------- .../api/inquiry/InquiryServiceTest.java | 35 ++++----- 3 files changed, 14 insertions(+), 144 deletions(-) delete mode 100644 src/main/java/com/example/api/inquiry/InquiryController.java delete mode 100644 src/test/java/com/example/api/inquiry/InquiryControllerTest.java diff --git a/src/main/java/com/example/api/inquiry/InquiryController.java b/src/main/java/com/example/api/inquiry/InquiryController.java deleted file mode 100644 index afc0c4a9..00000000 --- a/src/main/java/com/example/api/inquiry/InquiryController.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.example.api.inquiry; - -import com.example.api.domain.Account; -import com.example.api.domain.Inquiry; -import com.example.api.inquiry.InquiryService; -import com.example.api.inquiry.dto.InquiryRequest; -import com.example.api.inquiry.dto.InquiryResponse; -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/v1/support") -public class InquiryController { - private final InquiryService inquiryService; - - @PostMapping("/inquiry") - public ResponseEntity createInquiry( - @RequestBody final InquiryRequest inquiryRequest - ) { - final Inquiry inquiry = inquiryService.saveInquiry( - inquiryRequest, - inquiryRequest.createdBy() - ); - final InquiryResponse inquiryResponse = mapToResponse(inquiry); - return ResponseEntity.ok(inquiryResponse); - } - - @GetMapping("/my-inquiries") - public ResponseEntity> getMyInquiries( - @RequestParam(required = true) final Long accountId - ) { - final List inquiryResponses = inquiryService.getInquiriesByAccountId(accountId); - return ResponseEntity.ok(inquiryResponses); - } - - private InquiryResponse mapToResponse(Inquiry inquiry) { - return new InquiryResponse( - inquiry.getInquiryId(), - inquiry.getInquiryType(), - inquiry.getSubInquiryType(), - inquiry.getTitle(), - inquiry.getContent(), - inquiry.getInquiryStatus().name(), - inquiry.getAnswerDate(), - inquiry.getCreatedBy() - ); - } -} diff --git a/src/test/java/com/example/api/inquiry/InquiryControllerTest.java b/src/test/java/com/example/api/inquiry/InquiryControllerTest.java deleted file mode 100644 index e2358e47..00000000 --- a/src/test/java/com/example/api/inquiry/InquiryControllerTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.example.api.inquiry; - -import com.example.api.domain.Account; -import com.example.api.domain.Inquiry; -import com.example.api.global.BaseIntegrationTest; -import com.example.api.inquiry.dto.InquiryResponse; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import java.util.List; - -class InquiryControllerTest extends BaseIntegrationTest { - @Autowired - private InquiryController inquiryController; - - @Test - void getMyInquiries() { - Account account = new Account(); - account.setAccountId(1L); - Inquiry inquiry1 = new Inquiry(); - inquiry1.setInquiryId(1L); - inquiry1.setInquiryType("General"); - inquiry1.setTitle("Test Inquiry 1"); - inquiry1.setCreatedBy(account); - - Inquiry inquiry2 = new Inquiry(); - inquiry2.setInquiryId(2L); - inquiry2.setInquiryType("Support"); - inquiry2.setTitle("Test Inquiry 2"); - inquiry2.setCreatedBy(account); - - List expectedResponses = List.of( - new InquiryResponse( - inquiry1.getInquiryId(), - inquiry1.getInquiryType(), - inquiry1.getSubInquiryType(), - inquiry1.getTitle(), - inquiry1.getContent(), - inquiry1.getInquiryStatus().name(), - inquiry1.getAnswerDate(), - inquiry1.getCreatedBy() - ), - new InquiryResponse( - inquiry2.getInquiryId(), - inquiry2.getInquiryType(), - inquiry2.getSubInquiryType(), - inquiry2.getTitle(), - inquiry2.getContent(), - inquiry2.getInquiryStatus().name(), - inquiry2.getAnswerDate(), - inquiry2.getCreatedBy() - ) - ); - - ResponseEntity> response = inquiryController.getMyInquiries(1L); - - Assertions.assertNotNull(response); - Assertions.assertEquals(HttpStatus.OK, response.getStatusCode()); - List actualResponses = response.getBody(); - Assertions.assertNotNull(actualResponses); - Assertions.assertEquals(expectedResponses.size(), actualResponses.size()); - - for (int i = 0; i < expectedResponses.size(); i++) { - Assertions.assertEquals(expectedResponses.get(i).getInquiryId(), actualResponses.get(i).getInquiryId()); - Assertions.assertEquals(expectedResponses.get(i).getInquiryType(), actualResponses.get(i).getInquiryType()); - Assertions.assertEquals(expectedResponses.get(i).getTitle(), actualResponses.get(i).getTitle()); - } - } -} diff --git a/src/test/java/com/example/api/inquiry/InquiryServiceTest.java b/src/test/java/com/example/api/inquiry/InquiryServiceTest.java index 7b722a77..9445e74f 100644 --- a/src/test/java/com/example/api/inquiry/InquiryServiceTest.java +++ b/src/test/java/com/example/api/inquiry/InquiryServiceTest.java @@ -1,7 +1,7 @@ package com.example.api.inquiry; -<<<<<<< HEAD -<<<<<<< HEAD +import com.example.api.account.entity.Nationality; +import com.example.api.account.entity.UserRole; import com.example.api.account.repository.AccountRepository; import com.example.api.domain.Account; import com.example.api.domain.Inquiry; @@ -37,18 +37,17 @@ void setUp() { accountRepository.deleteAll(); inquiryRepository.deleteAll(); - Account account = new Account(); - account.setAccountId(1L); - account.setName("Alice"); - account.setEmail("alice@example.com"); - account.setAge(25); - account.setSex("F"); - account.setPhoneNumber("010-1234-5678"); - account.setProfileImage("user-uploads/1/profile.png"); - account.setStarPoint(4.5f); - account.setWorkCount(10); - account.setOpenStatus(true); - account.setDeleted(false); + Account account = new Account( + "user01", + "password123", + "Alice", + "nickname01", + "010-1234-5678", + "alice@example.com", + Nationality.KOREAN, + List.of(UserRole.EMPLOYEE), + false + ); accountRepository.save(account); } @@ -113,10 +112,4 @@ void mapToInquiry_shouldMapCommandToInquiry() { assertThat(inquiry).isNotNull(); assertThat(inquiry.getTitle()).isEqualTo("Test Title"); } -======= -public class InquiryServiceController { ->>>>>>> 2f6b5cc (#53 feat(ReviewCommand): DTO 작성) -======= -public class InquiryServiceTest { ->>>>>>> 0ff3ba1 (#53 feat(ReviewService): 서비스 코드 구현) -} +} \ No newline at end of file From e147e9535257ed01da9b48176cb7fc765fea982b Mon Sep 17 00:00:00 2001 From: yuna83 Date: Sat, 4 Jan 2025 15:46:31 +0900 Subject: [PATCH 05/10] =?UTF-8?q?#53=20test(ReviewControllerTest):=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../api/location/LocationRepository.java | 4 ++ .../example/api/location/LocationService.java | 4 ++ .../controller/LocationController.java | 4 ++ .../location/dto/GoolglePlaceResponse.java | 4 ++ .../location/dto/LocationSearchCommand.java | 4 ++ .../location/dto/LocationSearchRequest.java | 4 ++ .../controller/ReviewControllerTest.java | 65 +++++++++++++++++++ .../api/review/service/ReviewServiceTest.java | 41 ++++++++++++ 9 files changed, 131 insertions(+) create mode 100644 src/main/java/com/example/api/location/LocationRepository.java create mode 100644 src/main/java/com/example/api/location/LocationService.java create mode 100644 src/main/java/com/example/api/location/controller/LocationController.java create mode 100644 src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java create mode 100644 src/main/java/com/example/api/location/dto/LocationSearchCommand.java create mode 100644 src/main/java/com/example/api/location/dto/LocationSearchRequest.java create mode 100644 src/test/java/com/example/api/review/controller/ReviewControllerTest.java create mode 100644 src/test/java/com/example/api/review/service/ReviewServiceTest.java diff --git a/build.gradle b/build.gradle index d8135831..570addf6 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.3.5' id 'io.spring.dependency-management' version '1.1.6' + id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10' } group = 'com.example' diff --git a/src/main/java/com/example/api/location/LocationRepository.java b/src/main/java/com/example/api/location/LocationRepository.java new file mode 100644 index 00000000..7aa0aa37 --- /dev/null +++ b/src/main/java/com/example/api/location/LocationRepository.java @@ -0,0 +1,4 @@ +package com.example.api.location; + +public interface LocationRepository { +} diff --git a/src/main/java/com/example/api/location/LocationService.java b/src/main/java/com/example/api/location/LocationService.java new file mode 100644 index 00000000..f6306745 --- /dev/null +++ b/src/main/java/com/example/api/location/LocationService.java @@ -0,0 +1,4 @@ +package com.example.api.location; + +public class LocationService { +} diff --git a/src/main/java/com/example/api/location/controller/LocationController.java b/src/main/java/com/example/api/location/controller/LocationController.java new file mode 100644 index 00000000..93ab0520 --- /dev/null +++ b/src/main/java/com/example/api/location/controller/LocationController.java @@ -0,0 +1,4 @@ +package com.example.api.location.controller; + +public class LocationController { +} diff --git a/src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java b/src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java new file mode 100644 index 00000000..899adb20 --- /dev/null +++ b/src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java @@ -0,0 +1,4 @@ +package com.example.api.location.dto; + +public class GoolglePlaceResponse { +} diff --git a/src/main/java/com/example/api/location/dto/LocationSearchCommand.java b/src/main/java/com/example/api/location/dto/LocationSearchCommand.java new file mode 100644 index 00000000..2ac5bd76 --- /dev/null +++ b/src/main/java/com/example/api/location/dto/LocationSearchCommand.java @@ -0,0 +1,4 @@ +package com.example.api.location.dto; + +public class LocationSearchCommand { +} diff --git a/src/main/java/com/example/api/location/dto/LocationSearchRequest.java b/src/main/java/com/example/api/location/dto/LocationSearchRequest.java new file mode 100644 index 00000000..2754a554 --- /dev/null +++ b/src/main/java/com/example/api/location/dto/LocationSearchRequest.java @@ -0,0 +1,4 @@ +package com.example.api.location.dto; + +public class LocationSearchRequest { +} diff --git a/src/test/java/com/example/api/review/controller/ReviewControllerTest.java b/src/test/java/com/example/api/review/controller/ReviewControllerTest.java new file mode 100644 index 00000000..595e2ee6 --- /dev/null +++ b/src/test/java/com/example/api/review/controller/ReviewControllerTest.java @@ -0,0 +1,65 @@ +package com.example.api.review.controller; + +import com.example.api.review.ReviewService; +import com.example.api.review.dto.ReviewCommand; +import com.example.api.review.dto.ReviewResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.test.web.servlet.MockMvc; + +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; + +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@WebMvcTest(ReviewController.class) +public class ReviewControllerTest { + @Autowired + private MockMvc mockMvc; + + @Mock + private ReviewService reviewService; + + @InjectMocks + private ReviewController reviewController; + + private ReviewResponse reviewResponse1; + private ReviewResponse reviewResponse2; + + @BeforeEach + void setUp() { + reviewResponse1 = new ReviewResponse( + "Business A", 101L, LocalDateTime.now(), LocalDateTime.now(), 5, "Great service!"); + reviewResponse2 = new ReviewResponse( + "Business B", 102L, LocalDateTime.now(), LocalDateTime.now(), 4, "Good experience."); + } + + @Test + void testGetMyReviews() throws Exception { + when(reviewService.getReviews(any(ReviewCommand.class))) + .thenReturn(List.of(reviewResponse1, reviewResponse2)); + mockMvc.perform(get("/api/v1/info/my/reviews") + .param("accountId", "123")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.reviews").isArray()) + .andExpect(jsonPath("$.reviews[0].businessName").value("Business A")) + .andExpect(jsonPath("$.reviews[1].reviewContent").value("Good experience.")); + } + + @Test + void testGetMyReviewsNoData() throws Exception { + when(reviewService.getReviews(any(ReviewCommand.class))) + .thenReturn(Collections.emptyList()); + mockMvc.perform(get("/api/v1/info/my/reviews") + .param("accountId", "123")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.reviews").isEmpty()); + } +} diff --git a/src/test/java/com/example/api/review/service/ReviewServiceTest.java b/src/test/java/com/example/api/review/service/ReviewServiceTest.java new file mode 100644 index 00000000..bd8a6e44 --- /dev/null +++ b/src/test/java/com/example/api/review/service/ReviewServiceTest.java @@ -0,0 +1,41 @@ +package com.example.api.review.service; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.example.api.global.BaseIntegrationTest; +import com.example.api.review.ReviewService; +import com.example.api.review.dto.ReviewCommand; +import com.example.api.review.dto.ReviewResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest +public class ReviewServiceTest extends BaseIntegrationTest { + @Autowired + private ReviewService reviewService; + + @BeforeEach + void setUp() { + } + + @Test + void testGetReviews() { + ReviewCommand reviewCommand = new ReviewCommand(1L); + List reviews = reviewService.getReviews(reviewCommand); + assertThat(reviews).isNotEmpty(); + assertThat(reviews.get(0).businessName()).isEqualTo("Tech Solutions Inc."); + assertThat(reviews.get(0).reviewContent()).isEqualTo("Good work"); + } + + @Test + void testGetReviewsWhenNoReviews() { + ReviewCommand reviewCommand = new ReviewCommand(999L); + List reviews = reviewService.getReviews(reviewCommand); + assertThat(reviews).isEmpty(); + } +} + From 415bd21972a7c75d166725243d28aaa5801625db Mon Sep 17 00:00:00 2001 From: yuna83 Date: Sat, 4 Jan 2025 15:58:54 +0900 Subject: [PATCH 06/10] =?UTF-8?q?#53=20refactor(ReviewService):=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/api/location/LocationRepository.java | 4 ---- src/main/java/com/example/api/location/LocationService.java | 4 ---- .../example/api/location/controller/LocationController.java | 4 ---- .../com/example/api/location/dto/GoolglePlaceResponse.java | 4 ---- .../com/example/api/location/dto/LocationSearchCommand.java | 4 ---- .../com/example/api/location/dto/LocationSearchRequest.java | 4 ---- 6 files changed, 24 deletions(-) delete mode 100644 src/main/java/com/example/api/location/LocationRepository.java delete mode 100644 src/main/java/com/example/api/location/LocationService.java delete mode 100644 src/main/java/com/example/api/location/controller/LocationController.java delete mode 100644 src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java delete mode 100644 src/main/java/com/example/api/location/dto/LocationSearchCommand.java delete mode 100644 src/main/java/com/example/api/location/dto/LocationSearchRequest.java diff --git a/src/main/java/com/example/api/location/LocationRepository.java b/src/main/java/com/example/api/location/LocationRepository.java deleted file mode 100644 index 7aa0aa37..00000000 --- a/src/main/java/com/example/api/location/LocationRepository.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.example.api.location; - -public interface LocationRepository { -} diff --git a/src/main/java/com/example/api/location/LocationService.java b/src/main/java/com/example/api/location/LocationService.java deleted file mode 100644 index f6306745..00000000 --- a/src/main/java/com/example/api/location/LocationService.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.example.api.location; - -public class LocationService { -} diff --git a/src/main/java/com/example/api/location/controller/LocationController.java b/src/main/java/com/example/api/location/controller/LocationController.java deleted file mode 100644 index 93ab0520..00000000 --- a/src/main/java/com/example/api/location/controller/LocationController.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.example.api.location.controller; - -public class LocationController { -} diff --git a/src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java b/src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java deleted file mode 100644 index 899adb20..00000000 --- a/src/main/java/com/example/api/location/dto/GoolglePlaceResponse.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.example.api.location.dto; - -public class GoolglePlaceResponse { -} diff --git a/src/main/java/com/example/api/location/dto/LocationSearchCommand.java b/src/main/java/com/example/api/location/dto/LocationSearchCommand.java deleted file mode 100644 index 2ac5bd76..00000000 --- a/src/main/java/com/example/api/location/dto/LocationSearchCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.example.api.location.dto; - -public class LocationSearchCommand { -} diff --git a/src/main/java/com/example/api/location/dto/LocationSearchRequest.java b/src/main/java/com/example/api/location/dto/LocationSearchRequest.java deleted file mode 100644 index 2754a554..00000000 --- a/src/main/java/com/example/api/location/dto/LocationSearchRequest.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.example.api.location.dto; - -public class LocationSearchRequest { -} From b206e63fbdad4b59ae95a1595832d1535f1056b6 Mon Sep 17 00:00:00 2001 From: yuna83 Date: Sun, 5 Jan 2025 01:37:56 +0900 Subject: [PATCH 07/10] =?UTF-8?q?#53=20refactor(ReviewCommand):=20dto=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/api/review/dto/ReviewCommand.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/example/api/review/dto/ReviewCommand.java b/src/main/java/com/example/api/review/dto/ReviewCommand.java index 0a657404..58f47028 100644 --- a/src/main/java/com/example/api/review/dto/ReviewCommand.java +++ b/src/main/java/com/example/api/review/dto/ReviewCommand.java @@ -1,19 +1,7 @@ package com.example.api.review.dto; -import java.time.LocalDateTime; - public record ReviewCommand( - Long accountId, - String businessName, - Long businessId, - LocalDateTime contractSrartTime, - LocalDateTime contractEndTime, - int reviewStarPoint, - String reviewContent) { - - public ReviewCommand(Long accountId) { - this(accountId, null, null, null, null, 0, null); - } -} + Long accountId +){} From 41861f2e5801a7c63441537c9c2e6226d709326c Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 10:38:21 +0900 Subject: [PATCH 08/10] service fix --- src/main/java/com/example/api/review/ReviewService.java | 6 ++++-- .../java/com/example/api/review/dto/ReviewResponse.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/api/review/ReviewService.java b/src/main/java/com/example/api/review/ReviewService.java index bf807c77..5ab0109c 100644 --- a/src/main/java/com/example/api/review/ReviewService.java +++ b/src/main/java/com/example/api/review/ReviewService.java @@ -9,7 +9,7 @@ import java.util.List; import com.example.api.domain.Review; -import com.example.api.review.dto.*; +import com.example.api.review.dto.ReviewCommand; import java.time.LocalDateTime; @@ -36,7 +36,7 @@ public List getReviewsByEmployee(@Validated final Long reviewId) @Transactional public List getReviews(@Validated final ReviewCommand reviewCommand) { - List reviews = reviewRepository.findReviewsByEmployee_AccountId(reviewCommand.accountId()); + final List reviews = reviewRepository.findReviewsByEmployee_AccountId(reviewCommand.accountId()); return mapToReviewResponses(reviews); } @@ -59,6 +59,7 @@ private ReviewResponse mapToReviewResponse(final Review review) { final LocalDateTime contractEndTime = review.getContract().getContractEndTime(); final int reviewStarPoint = review.getReviewStarPoint(); final String reviewContent = review.getReviewContent(); + return new ReviewResponse( review.getReviewId(), businessName, @@ -70,3 +71,4 @@ private ReviewResponse mapToReviewResponse(final Review review) { ); } } + diff --git a/src/main/java/com/example/api/review/dto/ReviewResponse.java b/src/main/java/com/example/api/review/dto/ReviewResponse.java index a44bbcc2..9ee26ef6 100644 --- a/src/main/java/com/example/api/review/dto/ReviewResponse.java +++ b/src/main/java/com/example/api/review/dto/ReviewResponse.java @@ -12,7 +12,7 @@ public record ReviewResponse( int reviewStarPoint, String reviewContent ) { - public static ReviewResponse from(Review review) { + public static ReviewResponse from(final Review review) { return new ReviewResponse( review.getReviewId(), review.getContract().getOfferEmployment().getBusiness().getBusinessName(), @@ -25,3 +25,4 @@ public static ReviewResponse from(Review review) { } } + From cde1d50a0eccad8460cb0d7775b2f471ff1c73b9 Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 10:57:42 +0900 Subject: [PATCH 09/10] rebase --- src/main/java/com/example/api/review/dto/ReviewResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/api/review/dto/ReviewResponse.java b/src/main/java/com/example/api/review/dto/ReviewResponse.java index 9ee26ef6..cf42c2ec 100644 --- a/src/main/java/com/example/api/review/dto/ReviewResponse.java +++ b/src/main/java/com/example/api/review/dto/ReviewResponse.java @@ -4,7 +4,7 @@ import java.time.LocalDateTime; public record ReviewResponse( - Long reviewId, + Long reviewId, //Id String businessName, Long businessId, LocalDateTime contractStartTime, From 1ea453ee3c15be8c709dcb2c48aa33ea6240108e Mon Sep 17 00:00:00 2001 From: yuna83 Date: Thu, 16 Jan 2025 11:03:41 +0900 Subject: [PATCH 10/10] build fix --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 570addf6..ac26df6a 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,7 @@ dependencies { // Query DSL implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' - annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" + annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api"