package cn.com.qmth.stmms.biz.common.domain.card;

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

import java.util.Collections;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class CardPage {

    @JsonProperty("card_type")
    private int cardType;

    @JsonProperty("page_size")
    private String pageSize;

    @JsonProperty("page_image")
    private String pageImage;

    @JsonProperty("locator")
    private Locator locator = new Locator();

    @JsonProperty("fill_locator")
    private List<FillLocator> fillLocator = Collections.emptyList();

    @JsonProperty("check_area")
    private CheckArea checkArea = new CheckArea();

    @JsonProperty("info_area")
    private List<double[]> infoArea = Collections.emptyList();

    @JsonProperty("answer_area")
    private List<AnswerArea> answerArea = Collections.emptyList();

    @JsonProperty("barcode")
    private List<FieldArea> barcode = Collections.emptyList();

    @JsonProperty("qrcode")
    private List<FieldArea> qrcode = Collections.emptyList();

    @JsonProperty("fill_area")
    private List<FillArea> fillArea = Collections.emptyList();

    @JsonProperty("ocr_area")
    private List<FieldArea> ocrArea = Collections.emptyList();

    @JsonProperty("extension")
    private Extension extension = new Extension();

    public int getCardType() {
        return cardType;
    }

    public void setCardType(int cardType) {
        this.cardType = cardType;
    }

    public String getPageSize() {
        return pageSize;
    }

    public void setPageSize(String pageSize) {
        this.pageSize = pageSize;
    }

    public String getPageImage() {
        return pageImage;
    }

    public void setPageImage(String pageImage) {
        this.pageImage = pageImage;
    }

    public Locator getLocator() {
        return locator;
    }

    public void setLocator(Locator locator) {
        this.locator = locator;
    }

    public List<double[]> getInfoArea() {
        return infoArea;
    }

    public void setInfoArea(List<double[]> infoArea) {
        this.infoArea = infoArea;
    }

    public List<AnswerArea> getAnswerArea() {
        return answerArea;
    }

    public void setAnswerArea(List<AnswerArea> answerArea) {
        this.answerArea = answerArea;
    }

    public List<FillArea> getFillArea() {
        return fillArea;
    }

    public void setFillArea(List<FillArea> fillArea) {
        this.fillArea = fillArea;
    }

    public Extension getExtension() {
        return extension;
    }

    public void setExtension(Extension extension) {
        this.extension = extension;
    }

    public List<FillLocator> getFillLocator() {
        return fillLocator;
    }

    public void setFillLocator(List<FillLocator> fillLocator) {
        this.fillLocator = fillLocator;
    }

    public CheckArea getCheckArea() {
        return checkArea;
    }

    public void setCheckArea(CheckArea checkArea) {
        this.checkArea = checkArea;
    }

    public List<FieldArea> getBarcode() {
        return barcode;
    }

    public void setBarcode(List<FieldArea> barcode) {
        this.barcode = barcode;
    }

    public List<FieldArea> getQrcode() {
        return qrcode;
    }

    public void setQrcode(List<FieldArea> qrcode) {
        this.qrcode = qrcode;
    }

    public List<FieldArea> getOcrArea() {
        return ocrArea;
    }

    public void setOcrArea(List<FieldArea> ocrArea) {
        this.ocrArea = ocrArea;
    }

    /**
     * 输出到文件前，进行必要的字段值转换与处理
     */
    public void format() {
        //默认题卡类型
        if (cardType < 1 || cardType > 3) {
            cardType = 2;
        }
        //图片内容留空
        pageImage = "";
        //主观题答题区清空，避免影响遮盖模式
        answerArea.clear();
    }
}
