package com.qmth.teachcloud.mark.bean.omredit;

import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.qmth.teachcloud.mark.entity.ScanPaperPage;

public class OmrEditPaper {

    @NotNull(message = "paper.number不能为空")
    @Min(value = 1, message = "paper.number不能小于1")
    private Integer number;

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

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public List<OmrEditPage> getPages() {
        return pages;
    }

    public void setPages(List<OmrEditPage> pages) {
        this.pages = pages;
    }

    public void updatePage(ScanPaperPage page) {
        for (OmrEditPage pageEdit : pages) {
            if (pageEdit.getIndex().equals(page.getPageIndex())) {
                if (pageEdit.getAbsent() != null) {
                    page.setAbsent(pageEdit.getAbsent());
                }
                if (pageEdit.getBreach() != null) {
                    page.setBreach(pageEdit.getBreach());
                }
                if (pageEdit.getQuestion() != null) {
                    page.setQuestion(pageEdit.getQuestion());
                }
            }
        }
    }
}
