Skip to content

Commit 24dea27

Browse files
authored
Merge pull request #181 from ttakkeun/feat/180
[Feat] 문의 내용 조회 api 구현
2 parents ea09838 + 6017f55 commit 24dea27

File tree

7 files changed

+61
-13
lines changed

7 files changed

+61
-13
lines changed

src/main/java/ttakkeun/ttakkeun_server/config/FeignClientConfig.java

-9
This file was deleted.

src/main/java/ttakkeun/ttakkeun_server/controller/InquiryController.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public class InquiryController {
2222

2323
private final InquiryService inquiryService;
2424

25-
@Operation(summary = "문의하기")
25+
@Operation(summary = "문의하기 API")
2626
@PostMapping(value = "/add", consumes = "multipart/form-data")
2727
public ApiResponse<InquiryResponseDTO.AddResultDTO> add(
2828
@AuthenticationPrincipal Member member,
29-
@RequestParam("type") InquiryType inquiryType,
29+
@RequestParam InquiryType inquiryType,
3030
@RequestPart @Valid InquiryRequestDTO inquiryRequestDTO,
3131
@RequestPart(required = false) List<MultipartFile> multipartFile
3232
) {
@@ -36,4 +36,14 @@ public ApiResponse<InquiryResponseDTO.AddResultDTO> add(
3636

3737
return ApiResponse.onSuccess(resultDTO);
3838
}
39+
40+
@Operation(summary = "문의 내용 조회하기 API")
41+
@GetMapping(value = "/{inquiry_id}")
42+
public ApiResponse<List<InquiryResponseDTO.getResultDTO>> getInquiry(
43+
@AuthenticationPrincipal Member member
44+
) {
45+
List<InquiryResponseDTO.getResultDTO> resultDTO = inquiryService.getInquiry(member);
46+
47+
return ApiResponse.onSuccess(resultDTO);
48+
}
3949
}

src/main/java/ttakkeun/ttakkeun_server/controller/ProductController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public ApiResponse<List<RecommendProductDTO>> getSearchProductsFromNaver(
9090
}
9191

9292
@Operation(summary = "좋아요/취소 토글 API")
93-
@PatchMapping("/like/{product_id}")
93+
@PutMapping("/like/{product_id}")
9494
public ApiResponse<LikeResponseDTO.Result> toggleLikeProduct(
9595
@PathVariable Long product_id,
9696
@AuthenticationPrincipal Member member,

src/main/java/ttakkeun/ttakkeun_server/converter/InquiryConverter.java

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.stereotype.Component;
55
import org.springframework.web.multipart.MultipartFile;
66
import ttakkeun.ttakkeun_server.dto.inquiry.InquiryRequestDTO;
7+
import ttakkeun.ttakkeun_server.dto.inquiry.InquiryResponseDTO;
78
import ttakkeun.ttakkeun_server.entity.Inquiry;
89
import ttakkeun.ttakkeun_server.entity.InquiryImage;
910
import ttakkeun.ttakkeun_server.entity.Member;
@@ -53,4 +54,18 @@ public Inquiry toInquiry(
5354

5455
return inquiry;
5556
}
57+
58+
public InquiryResponseDTO.getResultDTO toDTO(Inquiry inquiry) {
59+
List<String> imageUrls = inquiry.getImages().stream()
60+
.map(InquiryImage::getImageUrl)
61+
.toList();
62+
63+
return InquiryResponseDTO.getResultDTO.builder()
64+
.contents(inquiry.getContents())
65+
.email(inquiry.getEmail())
66+
.created_at(inquiry.getCreatedAt())
67+
.inquiryType(inquiry.getInquiryType().toString())
68+
.imageUrl(imageUrls)
69+
.build();
70+
}
5671
}

src/main/java/ttakkeun/ttakkeun_server/dto/inquiry/InquiryResponseDTO.java

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import lombok.Getter;
66
import lombok.NoArgsConstructor;
77

8+
import java.time.LocalDateTime;
9+
import java.util.List;
10+
811
public class InquiryResponseDTO {
912
@Builder
1013
@Getter
@@ -13,4 +16,16 @@ public class InquiryResponseDTO {
1316
public static class AddResultDTO {
1417
Long inquiryId;
1518
}
19+
20+
@Builder
21+
@Getter
22+
@NoArgsConstructor
23+
@AllArgsConstructor
24+
public static class getResultDTO {
25+
String contents;
26+
String email;
27+
String inquiryType;
28+
List<String> imageUrl;
29+
LocalDateTime created_at;
30+
}
1631
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package ttakkeun.ttakkeun_server.repository;
22

3+
import org.springframework.data.domain.Page;
4+
import org.springframework.data.domain.Pageable;
35
import org.springframework.data.jpa.repository.JpaRepository;
46
import org.springframework.stereotype.Repository;
57
import ttakkeun.ttakkeun_server.entity.Inquiry;
8+
import ttakkeun.ttakkeun_server.entity.Member;
9+
10+
import java.util.List;
611

712
@Repository
813
public interface InquiryRepository extends JpaRepository<Inquiry, Long> {
9-
14+
List<Inquiry> findByMember(Member member);
1015
}

src/main/java/ttakkeun/ttakkeun_server/service/InquiryService.java

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import lombok.RequiredArgsConstructor;
55
import org.springframework.stereotype.Service;
66
import org.springframework.web.multipart.MultipartFile;
7+
import ttakkeun.ttakkeun_server.apiPayLoad.exception.ExceptionHandler;
78
import ttakkeun.ttakkeun_server.converter.InquiryConverter;
89
import ttakkeun.ttakkeun_server.dto.inquiry.InquiryRequestDTO;
910
import ttakkeun.ttakkeun_server.dto.inquiry.InquiryResponseDTO;
@@ -14,6 +15,9 @@
1415

1516
import java.util.List;
1617

18+
import static ttakkeun.ttakkeun_server.apiPayLoad.code.status.ErrorStatus.PET_NOT_FOUND;
19+
import static ttakkeun.ttakkeun_server.apiPayLoad.code.status.ErrorStatus._NOT_FOUND;
20+
1721
@Service
1822
@Transactional
1923
@RequiredArgsConstructor
@@ -40,4 +44,12 @@ public InquiryResponseDTO.AddResultDTO addInquiry(
4044
.inquiryId(newInquiry.getInquiryId())
4145
.build();
4246
}
47+
48+
public List<InquiryResponseDTO.getResultDTO> getInquiry(Member member) {
49+
List<Inquiry> inquiries = inquiryRepository.findByMember(member);
50+
51+
return inquiries.stream()
52+
.map(inquiryConverter::toDTO)
53+
.toList();
54+
}
4355
}

0 commit comments

Comments
 (0)