Skip to content

Commit

Permalink
Merge pull request #33 from ZoneBUG/feat/report
Browse files Browse the repository at this point in the history
feat : ReportResponseDTO 형식 변경
  • Loading branch information
seoyamin authored May 17, 2023
2 parents 534fc8c + 6b3cbf6 commit c16fdc1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/zonebug/debugging/dto/ReportItemDTO.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,11 +15,6 @@
@NoArgsConstructor
public class ReportResponseDTO {


private List<ReportImageDTO> reportImageDTO;

private List<CheckListDTO> checkListDTO;

private List<DrugListDTO> drugListDTO;
private List<ReportItemDTO> reportItemDTO;

}
23 changes: 7 additions & 16 deletions src/main/java/com/zonebug/debugging/service/ReportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,36 +43,26 @@ public ReportResponseDTO getReport(CustomUserDetails authUser, Integer period) {
spec = spec.and(ScenarioSpecification.findScenario(period, user));
List<Scenario> scenarioList = scenarioRepository.findAll(spec);

List<ReportImageDTO> reportImageDTO = new ArrayList<>();
List<Bug> bugList = new ArrayList<>();
List<ReportItemDTO> reportItemDTOList = new ArrayList<>();

for(Scenario s : scenarioList){
String image = s.getImage();
Bug bug = s.getBug();
String bugName = bug.getSpecies();
Date date = s.getCreatedAt();
ReportImageDTO data = new ReportImageDTO(image, bugName, date);
bugList.add(bug);
reportImageDTO.add(data);
}

List<CheckListDTO> checkListDTO = new ArrayList<>();
List<DrugListDTO> drugListDTO = new ArrayList<>();

for(Bug bug : bugList){
String bugName = bug.getSpecies();

System.out.println(checkListRepository.findContentsByBug(bug));

List<String> checkListContents = checkListRepository.findContentsByBug(bug);
CheckListDTO checkListData = new CheckListDTO(bugName, checkListContents);
checkListDTO.add(checkListData);

List<Drug> 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);
}
}

0 comments on commit c16fdc1

Please sign in to comment.