Search in sources :

Example 1 with ReportStudylog

use of wooteco.prolog.report.domain.ReportStudylog 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);
}
Also used : Report(wooteco.prolog.report.domain.Report) ReportAbility(wooteco.prolog.report.domain.ReportAbility) ReportStudylog(wooteco.prolog.report.domain.ReportStudylog)

Example 2 with ReportStudylog

use of wooteco.prolog.report.domain.ReportStudylog in project prolog by woowacourse.

the class ReportStudylogResponse method of.

public static ReportStudylogResponse of(Studylog studylog, List<ReportStudylog> reportStudylogs) {
    StudylogResponse studylogResponse = StudylogResponse.of(studylog);
    List<ReportAbilityResponse> abilityResponses = reportStudylogs.stream().map(it -> ReportAbilityResponse.of(it.getReportAbility())).collect(Collectors.toList());
    List<ReportStudylogAbilityResponse> studylogAbilityResponses = reportStudylogs.stream().map(it -> ReportStudylogAbilityResponse.of(it.getStudylogAbility())).collect(Collectors.toList());
    return new ReportStudylogResponse(studylogResponse, abilityResponses, studylogAbilityResponses);
}
Also used : List(java.util.List) ReportStudylog(wooteco.prolog.report.domain.ReportStudylog) Getter(lombok.Getter) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) Studylog(wooteco.prolog.studylog.domain.Studylog) AllArgsConstructor(lombok.AllArgsConstructor) Collectors(java.util.stream.Collectors) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse)

Example 3 with ReportStudylog

use of wooteco.prolog.report.domain.ReportStudylog 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);
}
Also used : StudylogAbility(wooteco.prolog.ability.domain.StudylogAbility) Report(wooteco.prolog.report.domain.Report) HierarchyAbilityResponse(wooteco.prolog.ability.application.dto.HierarchyAbilityResponse) ReportAbility(wooteco.prolog.report.domain.ReportAbility) ReportStudylog(wooteco.prolog.report.domain.ReportStudylog) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ReportStudylog (wooteco.prolog.report.domain.ReportStudylog)3 Report (wooteco.prolog.report.domain.Report)2 ReportAbility (wooteco.prolog.report.domain.ReportAbility)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Getter (lombok.Getter)1 Transactional (org.springframework.transaction.annotation.Transactional)1 HierarchyAbilityResponse (wooteco.prolog.ability.application.dto.HierarchyAbilityResponse)1 StudylogAbility (wooteco.prolog.ability.domain.StudylogAbility)1 StudylogResponse (wooteco.prolog.studylog.application.dto.StudylogResponse)1 Studylog (wooteco.prolog.studylog.domain.Studylog)1