package cn.yunzhixue.ability.center.examsprint.application.report;

import cn.yunzhixue.ability.center.examsprint.contracts.report.AchievementExamSprintReportPayload;
import cn.yunzhixue.ability.center.examsprint.domain.report.AchievementReportContent;

import java.util.Objects;

final class AchievementReportContentMapper {

    private AchievementReportContentMapper() {
    }

    static AchievementReportContent toDomainContent(AchievementExamSprintReportPayload payload) {
        Objects.requireNonNull(payload, "payload");
        return new AchievementReportContent(
                payload.studentName(),
                payload.reportTitle(),
                payload.reportSubtitle(),
                payload.completionTitle(),
                payload.completionSubtitle(),
                new AchievementReportContent.SummaryMetrics(
                        payload.summaryMetrics().vocabularyGrowthText(),
                        payload.summaryMetrics().paperKnownWordsGrowthText(),
                        payload.summaryMetrics().unknownWordHitRateText(),
                        payload.summaryMetrics().learningEfficiencyText()),
                comparison(payload.vocabularyComparison()),
                comparison(payload.paperKnownWordsComparison()),
                new AchievementReportContent.ExamUnknownWordsHitStatus(
                        payload.examUnknownWordsHitStatus().unknownWordHitRateText(),
                        payload.examUnknownWordsHitStatus().learningEfficiencyText(),
                        payload.examUnknownWordsHitStatus().unknownWordsBeforeText(),
                        payload.examUnknownWordsHitStatus().unknownWordsAfterText(),
                        payload.examUnknownWordsHitStatus().reducedUnknownWordsText(),
                        payload.examUnknownWordsHitStatus().hitWords()));
    }

    private static AchievementReportContent.Comparison comparison(AchievementExamSprintReportPayload.Comparison comparison) {
        return new AchievementReportContent.Comparison(
                comparison.beforeValue(),
                comparison.afterValue(),
                comparison.beforeText(),
                comparison.afterText(),
                comparison.growthText());
    }
}
