Skip to content
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

[fix] 리뷰 조회 파라미터 수정 #35

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Service
@RequiredArgsConstructor
Expand All @@ -25,14 +26,24 @@ public class RecordGetService {
private final KeywordQueryService keywordQueryService;
private final MovieQueryService movieQueryService;

public RecordResponse.RecordDetailResponse getRecord(Long recordId) {
Record record = recordQueryService.findById(recordId);
List<Keyword> keywordList = keywordQueryService.findByRecordId(recordId);
List<String> keywords= new ArrayList<>();
for(Keyword keyword : keywordList){
keywords.add(keyword.getWord());
public RecordResponse.RecordDetailResponse getRecord(Long userId, Long movieId) {
Optional<Record> record = recordQueryService.findByUserIdAndMovieId(userId, movieId);
if(record.isEmpty()) {
return RecordResponse.RecordDetailResponse.builder()
.date(null)
.keywords(null)
.rating(null)
.review(null)
.build();
}
else {
List<Keyword> keywordList = keywordQueryService.findByRecordId(record.get().getId());
List<String> keywords = new ArrayList<>();
for (Keyword keyword : keywordList) {
keywords.add(keyword.getWord());
}
return RecordMapper.mapToRecordDetailResponse(record.get(), keywords);
}
return RecordMapper.mapToRecordDetailResponse(record, keywords);
}

public List<List<RecordResponse.RecordCalendarResponse>> getRecordByCalendar(String year, String month) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public void createRecord(@RequestBody RecordRequest.RecordCreateRequest recordCr
recordCreateService.createRecord(recordCreateRequest);
}

@GetMapping("/record/{recordId}")
public RecordResponse.RecordDetailResponse getRecord(@PathVariable Long recordId) {
return recordGetService.getRecord(recordId);
@GetMapping("/record")
public RecordResponse.RecordDetailResponse getRecord(@RequestParam Long userId, @RequestParam Long movieId) {
return recordGetService.getRecord(userId, movieId);
}

@DeleteMapping("/record")
Expand Down
Loading