package com.qmth.boot.core.ai.model.llm.score;

import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 自动评分请求参数
 */
@Validated
public class AutoScoreRequest implements Serializable {

    private static final long serialVersionUID = 6487765658648836214L;

    @NotBlank(message = "科目名称不能为空")
    private String subjectName;

    @NotBlank(message = "试题内容不能为空")
    private String questionBody;

    @NotNull(message = "评分模式")
    private AutoScoreModel scoreModel;

    @Valid
    @NotNull(message = "标答不能为空")
    @Size(min = 1, message = "标答不能为空")
    private List<StandardAnswer> standardAnswer = new ArrayList<>();

    @NotNull(message = "考生回答不能为空")
    private String studentAnswer;

    /**
     * 试题总分
     */
    private double totalScore;

    /**
     * 最小间隔分
     */
    private double intervalScore = 1;

    /**
     * 增加标答内容及分值
     *
     * @param content 标答内容
     * @param score   按得分点-分值
     */
    public AutoScoreRequest addStandardAnswer(@NotNull String content, double score) {
        StandardAnswer answer = new StandardAnswer();
        answer.setContent(content);
        answer.setScore(score);
        this.standardAnswer.add(answer);
        return this;
    }

    /**
     * 增加标答内容及分值
     *
     * @param content   标答内容
     * @param lowScore  按档次-最低分值
     * @param highScore 按档次-最高分值
     */
    public AutoScoreRequest addStandardAnswer(@NotNull String content, double lowScore, double highScore) {
        StandardAnswer answer = new StandardAnswer();
        answer.setContent(content);
        answer.setLowScore(lowScore);
        answer.setHighScore(highScore);
        this.standardAnswer.add(answer);
        return this;
    }

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getQuestionBody() {
        return questionBody;
    }

    public void setQuestionBody(String questionBody) {
        this.questionBody = questionBody;
    }

    public AutoScoreModel getScoreModel() {
        return scoreModel;
    }

    public void setScoreModel(AutoScoreModel scoreModel) {
        this.scoreModel = scoreModel;
    }

    public List<StandardAnswer> getStandardAnswer() {
        return standardAnswer;
    }

    public void setStandardAnswer(List<StandardAnswer> standardAnswer) {
        this.standardAnswer = standardAnswer;
    }

    public String getStudentAnswer() {
        return studentAnswer;
    }

    public void setStudentAnswer(String studentAnswer) {
        this.studentAnswer = studentAnswer;
    }

    public double getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(double totalScore) {
        this.totalScore = totalScore;
    }

    public double getIntervalScore() {
        return intervalScore;
    }

    public void setIntervalScore(double intervalScore) {
        this.intervalScore = intervalScore;
    }

}
