use of wooteco.prolog.report.domain.ReportAbility in project prolog by woowacourse.
the class ReportService method findReportById.
public ReportResponse findReportById(Long reportId) {
Report persistReport = reportRepository.findById(reportId).orElseThrow(IllegalArgumentException::new);
List<ReportAbility> persistReportAbilities = reportAbilityRepository.findByReportId(persistReport.getId());
List<ReportStudylog> persistReportStudylogs = reportStudylogRepository.findByReportId(persistReport.getId());
return ReportResponse.of(persistReport, persistReportAbilities, persistReportStudylogs);
}
use of wooteco.prolog.report.domain.ReportAbility in project prolog by woowacourse.
the class ReportService method createReport.
@Transactional
public ReportResponse createReport(LoginMember loginMember, ReportRequest reportRequest) {
Report report = reportRepository.save(new Report(reportRequest.getTitle(), reportRequest.getDescription(), loginMember.getId(), LocalDate.parse(reportRequest.getStartDate()), LocalDate.parse(reportRequest.getEndDate())));
List<HierarchyAbilityResponse> abilities = abilityService.findParentAbilitiesByMemberId(loginMember.getId());
List<ReportAbility> reportAbilities = reportAbilityRepository.saveAll(abilities.stream().map(it -> new ReportAbility(it.getName(), it.getDescription(), it.getColor(), reportRequest.findWeight(it.getId()), it.getId(), report.getId())).collect(Collectors.toList()));
List<StudylogAbility> studylogAbilities = studylogAbilityService.findStudylogAbilitiesInPeriod(loginMember.getId(), LocalDate.parse(reportRequest.getStartDate()), LocalDate.parse(reportRequest.getEndDate()));
List<ReportStudylog> reportStudylogs = reportStudylogRepository.saveAll(studylogAbilities.stream().map(it -> new ReportStudylog(report.getId(), findReportAbilityByAbility(it.getAbility(), reportAbilities), it.getStudylog(), it.getAbility().getName(), it.getAbility().getColor())).collect(Collectors.toList()));
return ReportResponse.of(report, reportAbilities, reportStudylogs);
}
Aggregations