From 6b3cbf6db22129aac78075e50332e44cc679851f Mon Sep 17 00:00:00 2001 From: seoyamin Date: Thu, 18 May 2023 03:13:42 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20ReportResponseDTO=20=ED=98=95?= =?UTF-8?q?=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zonebug/debugging/dto/ReportItemDTO.java | 21 +++++++++++++++++ .../dto/response/ReportResponseDTO.java | 8 ++----- .../debugging/service/ReportService.java | 23 ++++++------------- 3 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/zonebug/debugging/dto/ReportItemDTO.java diff --git a/src/main/java/com/zonebug/debugging/dto/ReportItemDTO.java b/src/main/java/com/zonebug/debugging/dto/ReportItemDTO.java new file mode 100644 index 0000000..95d7d6f --- /dev/null +++ b/src/main/java/com/zonebug/debugging/dto/ReportItemDTO.java @@ -0,0 +1,21 @@ +package com.zonebug.debugging.dto; + +import jakarta.validation.constraints.NotNull; +import lombok.*; + +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ReportItemDTO { + + @NotNull + private ReportImageDTO reportImageDTO; + + @NotNull + private CheckListDTO checkListDTO; + + @NotNull + private DrugListDTO drugListDTO; +} diff --git a/src/main/java/com/zonebug/debugging/dto/response/ReportResponseDTO.java b/src/main/java/com/zonebug/debugging/dto/response/ReportResponseDTO.java index b5f369b..bea7172 100644 --- a/src/main/java/com/zonebug/debugging/dto/response/ReportResponseDTO.java +++ b/src/main/java/com/zonebug/debugging/dto/response/ReportResponseDTO.java @@ -3,6 +3,7 @@ import com.zonebug.debugging.dto.CheckListDTO; import com.zonebug.debugging.dto.DrugListDTO; import com.zonebug.debugging.dto.ReportImageDTO; +import com.zonebug.debugging.dto.ReportItemDTO; import lombok.*; import java.util.List; @@ -14,11 +15,6 @@ @NoArgsConstructor public class ReportResponseDTO { - - private List reportImageDTO; - - private List checkListDTO; - - private List drugListDTO; + private List reportItemDTO; } diff --git a/src/main/java/com/zonebug/debugging/service/ReportService.java b/src/main/java/com/zonebug/debugging/service/ReportService.java index 78b4813..9c7b857 100644 --- a/src/main/java/com/zonebug/debugging/service/ReportService.java +++ b/src/main/java/com/zonebug/debugging/service/ReportService.java @@ -12,6 +12,7 @@ import com.zonebug.debugging.dto.CheckListDTO; import com.zonebug.debugging.dto.DrugListDTO; import com.zonebug.debugging.dto.ReportImageDTO; +import com.zonebug.debugging.dto.ReportItemDTO; import com.zonebug.debugging.dto.response.ReportResponseDTO; import com.zonebug.debugging.security.user.CustomUserDetails; import lombok.RequiredArgsConstructor; @@ -42,8 +43,7 @@ public ReportResponseDTO getReport(CustomUserDetails authUser, Integer period) { spec = spec.and(ScenarioSpecification.findScenario(period, user)); List scenarioList = scenarioRepository.findAll(spec); - List reportImageDTO = new ArrayList<>(); - List bugList = new ArrayList<>(); + List reportItemDTOList = new ArrayList<>(); for(Scenario s : scenarioList){ String image = s.getImage(); @@ -51,27 +51,18 @@ public ReportResponseDTO getReport(CustomUserDetails authUser, Integer period) { String bugName = bug.getSpecies(); Date date = s.getCreatedAt(); ReportImageDTO data = new ReportImageDTO(image, bugName, date); - bugList.add(bug); - reportImageDTO.add(data); - } - - List checkListDTO = new ArrayList<>(); - List drugListDTO = new ArrayList<>(); - - for(Bug bug : bugList){ - String bugName = bug.getSpecies(); - - System.out.println(checkListRepository.findContentsByBug(bug)); List checkListContents = checkListRepository.findContentsByBug(bug); CheckListDTO checkListData = new CheckListDTO(bugName, checkListContents); - checkListDTO.add(checkListData); List drugListContents = drugRepository.findByBug(bug); DrugListDTO drugListData = new DrugListDTO(bugName, drugListContents); - drugListDTO.add(drugListData); + + ReportItemDTO reportItem = new ReportItemDTO(data, checkListData, drugListData); + reportItemDTOList.add(reportItem); } - return new ReportResponseDTO(reportImageDTO, checkListDTO, drugListDTO); + + return new ReportResponseDTO(reportItemDTOList); } }