package com.seer.teach.teacher.common.resp;

import com.seer.teach.teacher.common.dto.SubjectTag;
import com.seer.teach.teacher.common.utils.HtmlBuildUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *
 * </p >
 *
 * @author Captain
 * @since 2025-08-09 13:51
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Schema(description = "报告返回实体类")
public class ReportResp {

    @Schema(description = "做题时间")
    private String time;

    @Schema(description = "单科得分")
    private List<SubjectScoreResp> subjectDetail;

    @Schema(description = "题目总数")
    private Integer questionCount;

    @Schema(description = "正确率")
    private Integer rightRate;

    @Schema(description = "错误率")
    private Integer wrongRate;

    @Schema(description = "单科题目数量")
    private List<SubjectReportResp> subjectQuestionCounts;

    @Schema(description = "标签")
    private List<SubjectTag> labels;

    @Schema(description = "潜能概述")
    private String potentialSummary;

    @Schema(description = "综合得分")
    private String score;

    @Schema(description = "超越率")
    private String overRate;

    /**
     * 构造一个字段为空的 ReportResp
     * @return ReportResp 空对象（字段为 null 或 0）
     */
    public static ReportResp buildEmptyReport(List<String> subject) {
        ReportResp resp = new ReportResp();
        resp.setTime(HtmlBuildUtils.formatStudyTimeHtml(0));
        List<SubjectScoreResp> scores = subject.stream().map(s -> new SubjectScoreResp(s, 0)).collect(Collectors.toList());
        resp.setSubjectDetail(scores);
        resp.setQuestionCount(0);
        resp.setRightRate(0);
        resp.setWrongRate(0);
        List<SubjectReportResp> reports = subject.stream().map(s -> new SubjectReportResp(s, 0)).collect(Collectors.toList());
        resp.setSubjectQuestionCounts(reports);
        resp.setLabels(new ArrayList<>());
        resp.setPotentialSummary(null);
        resp.setScore(HtmlBuildUtils.formatScoreHtml(0));
        resp.setOverRate(HtmlBuildUtils.formatSurpassHtml(0));
        return resp;
    }
}