package com.qmth.teachcloud.mark.dto.refix;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

public class AnswerRefixDomain {

    @NotNull(message = "考生Id不能为空")
    private Long studentId;

    @NotNull(message = "卡格式编号不能为空")
    @Min(value = 1, message = "卡格式编号不能小于1")
    private Integer cardNumber;

    @Valid
    @NotNull(message = "paper不能为空")
    @Size(min = 1, message = "paper不能为空")
    private List<PaperRefixDomain> papers;

    public Long getStudentId() {
        return studentId;
    }

    public void setStudentId(Long studentId) {
        this.studentId = studentId;
    }

    public Integer getCardNumber() {
        return cardNumber;
    }

    public void setCardNumber(Integer cardNumber) {
        this.cardNumber = cardNumber;
    }

    public List<PaperRefixDomain> getPapers() {
        return papers;
    }

    public void setPapers(List<PaperRefixDomain> papers) {
        this.papers = papers;
    }

    public PaperRefixDomain findPaperDomain(Integer paperIndex, Long paperId) {
        for (PaperRefixDomain domain : papers) {
            if (domain.getId().equals(paperId) && domain.getNumber().equals(paperIndex)) {
                return domain;
            }
        }
        return null;
    }
}
