package com.ssj.service.conch.teacher.app.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

public class HomeworkPictureDTO implements Serializable {

    private static final long serialVersionUID = 8314861558937601459L;

    private String homeworkPictureId;
    private String fileKey;
    private Integer isFeedback;
    private Integer status;
    private Integer secondType;
    private String correctedPictureUrl;
    private Integer taskStatus;
    private Integer dealFlag;
    private Integer discernType;
    private String bookId;
    private String unitId;
    private String periodId;

    @JSONField(serialize = false)
    private String pageIndexStr;
    private Object[] pageIndexs;

    @JSONField(serialize = false)
    private String questionIdStr;
    private List<String> questionIds;

    @JSONField(serialize = false)
    private String teacherId;
    @JSONField(serialize = false)
    private Integer isMark;
    private Integer compositionCorrected;
    @JSONField(serialize = false)
    private Integer isCorrect;

    private String homeworkComment;

    public String getHomeworkComment() {
        return homeworkComment;
    }

    public void setHomeworkComment(String homeworkComment) {
        this.homeworkComment = homeworkComment;
    }

    public String getHomeworkPictureId() {
        return homeworkPictureId;
    }

    public void setHomeworkPictureId(String homeworkPictureId) {
        this.homeworkPictureId = homeworkPictureId;
    }

    public String getFileKey() {
        return fileKey;
    }

    public void setFileKey(String fileKey) {
        this.fileKey = fileKey;
    }

    public Integer getIsFeedback() {
        return isFeedback;
    }

    public void setIsFeedback(Integer isFeedback) {
        this.isFeedback = isFeedback;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getCorrectedPictureUrl() {
        return correctedPictureUrl;
    }

    public void setCorrectedPictureUrl(String correctedPictureUrl) {
        this.correctedPictureUrl = correctedPictureUrl;
    }

    public Integer getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(Integer taskStatus) {
        this.taskStatus = taskStatus;
    }

    public Integer getDealFlag() {
        return dealFlag;
    }

    public void setDealFlag(Integer dealFlag) {
        this.dealFlag = dealFlag;
    }

    public Integer getDiscernType() {
        if (Objects.equals(1, taskStatus)) {
            //识别成功，判断是否匹配到练习册
            return dealFlag > 0 ? 1 : 3;
        } else {
            //识别中或识别失败
            return taskStatus;
        }
    }

    public String getBookId() {
        return bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getUnitId() {
        return unitId;
    }

    public void setUnitId(String unitId) {
        this.unitId = unitId;
    }

    public String getPeriodId() {
        return periodId;
    }

    public void setPeriodId(String periodId) {
        this.periodId = periodId;
    }

    public String getPageIndexStr() {
        return pageIndexStr;
    }

    public void setPageIndexStr(String pageIndexStr) {
        this.pageIndexStr = pageIndexStr;
    }

    public Object[] getPageIndexs() {
        if (StringUtils.isBlank(pageIndexStr)) {
            pageIndexs = Collections.emptyList().toArray();
        } else {
            pageIndexs = JSON.parseArray(pageIndexStr).toArray();
        }
        return pageIndexs;
    }

    public String getQuestionIdStr() {
        return questionIdStr;
    }

    public void setQuestionIdStr(String questionIdStr) {
        this.questionIdStr = questionIdStr;
    }

    public List<String> getQuestionIds() {
        if (StringUtils.isNotBlank(questionIdStr)) {
            return JSON.parseArray(questionIdStr).toJavaList(String.class);
        }
        return Collections.emptyList();
    }

    public String getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }

    public Integer getIsMark() {
        return isMark;
    }

    public void setIsMark(Integer isMark) {
        this.isMark = isMark;
    }

    public Integer getCompositionCorrected() {
        return compositionCorrected;
    }

    public void setCompositionCorrected(Integer compositionCorrected) {
        this.compositionCorrected = compositionCorrected;
    }

    public Integer getIsCorrect() {
        return isCorrect;
    }

    public void setIsCorrect(Integer isCorrect) {
        this.isCorrect = isCorrect;
    }

    public Integer getSecondType() {
        return secondType;
    }

    public void setSecondType(Integer secondType) {
        this.secondType = secondType;
    }
}
