
package top.tqx.demo_1.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ExamGradeResponse implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonProperty("success")
    private Boolean success;

    @JsonProperty("status")
    private String status;

    @JsonProperty("status_code")
    private Integer statusCode;

    @JsonProperty("message")
    private String message;

    @JsonProperty("data")
    private ExamGradeData data;

    @JsonProperty("error")
    private String error;

    @JsonProperty("error_code")
    private String errorCode;

    public Boolean getSuccess() {
        if (success != null) {
            return success;
        }
        if (data != null) {
            return data.getSuccess();
        }
        return null;
    }

    public String getRequestId() {
        if (data != null) {
            return data.getRequestId();
        }
        return requestId;
    }

    public String getPaperId() {
        if (data != null) {
            return data.getPaperId();
        }
        return paperId;
    }

    public BigDecimal getTotalScore() {
        if (data != null) {
            return data.getTotalScore();
        }
        return totalScore;
    }

    public BigDecimal getTotalMaxScore() {
        if (data != null) {
            return data.getTotalMaxScore();
        }
        return totalMaxScore;
    }

    public BigDecimal getScoreRate() {
        if (data != null) {
            return data.getScoreRate();
        }
        return scoreRate;
    }

    public List<GradeResult> getResults() {
        if (data != null) {
            return data.getResults();
        }
        return results;
    }

    @JsonProperty("request_id")
    private String requestId;

    @JsonProperty("paper_id")
    private String paperId;

    @JsonProperty("total_score")
    private BigDecimal totalScore;

    @JsonProperty("total_max_score")
    private BigDecimal totalMaxScore;

    @JsonProperty("score_rate")
    private BigDecimal scoreRate;

    @JsonProperty("results")
    private List<GradeResult> results;

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class ExamGradeData implements Serializable {
        private static final long serialVersionUID = 1L;

        @JsonProperty("success")
        private Boolean success;

        @JsonProperty("request_id")
        private String requestId;

        @JsonProperty("paper_id")
        private String paperId;

        @JsonProperty("total_score")
        private BigDecimal totalScore;

        @JsonProperty("total_max_score")
        private BigDecimal totalMaxScore;

        @JsonProperty("score_rate")
        private BigDecimal scoreRate;

        @JsonProperty("results")
        private List<GradeResult> results;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class GradeResult implements Serializable {
        private static final long serialVersionUID = 1L;

        @JsonProperty("question_id")
        private String questionId;

        @JsonProperty("question_type")
        private String questionType;

        @JsonProperty("score")
        private BigDecimal score;

        @JsonProperty("max_score")
        private BigDecimal maxScore;

        @JsonProperty("correct")
        private Boolean correct;

        @JsonProperty("is_correct")
        private Boolean isCorrect;

        @JsonProperty("student_answer")
        private Object studentAnswer;

        @JsonProperty("correct_answer")
        private Object correctAnswer;

        @JsonProperty("correct_answers")
        private List<String> correctAnswers;

        @JsonProperty("feedback")
        private String feedback;

        @JsonProperty("details")
        private DetailInfo details;

        @Data
        @JsonIgnoreProperties(ignoreUnknown = true)
        public static class DetailInfo implements Serializable {
            private static final long serialVersionUID = 1L;

            @JsonProperty("highlights")
            private List<String> highlights;

            @JsonProperty("overall_feedback")
            private String overallFeedback;

            @JsonProperty("scoring_breakdown")
            private List<ScoringBreakdown> scoringBreakdown;

            @JsonProperty("shortcomings")
            private List<String> shortcomings;
        }

        @Data
        @JsonIgnoreProperties(ignoreUnknown = true)
        public static class ScoringBreakdown implements Serializable {
            private static final long serialVersionUID = 1L;

            @JsonProperty("point")
            private String point;

            @JsonProperty("weight")
            private Double weight;

            @JsonProperty("achieved")
            private Double achieved;

            @JsonProperty("comment")
            private String comment;
        }
    }
}

