package com.ssj.service.conch.game.request;

import com.ssj.bean.common.framework.core.domain.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author yrf
 * @description
 * @time 2020/4/17 16:24
 */
public class AnswerInfoSaveReq extends BaseRequest {

    private static final long serialVersionUID = -886870858073312960L;

    /**
     * 可存储最大用时为半小时，单位：ms
     */
    private static final int MAX_USED_TIME = 30 * 60 * 1000;

    @ApiModelProperty(name = "gameRespondentId", value = "答题人id", required = true)
    @NotBlank
    private String gameRespondentId;

    @ApiModelProperty(name = "moduleCode", value = "题目所属维度代号(1：心理旋转，2：空间想象，3：图形推理，4：视觉搜索，5：工作记忆，6：执行功能)", required = true)
    @NotNull
    @Min(1)
    @Max(6)
    private Integer moduleCode;

    @ApiModelProperty(name = "questionCode", value = "题目代号(1表示第1题，以此类推)", required = true)
    @NotNull
    @Min(1)
    private Integer questionCode;

    @ApiModelProperty(name = "usedTime", value = "答题用时，单位：ms", required = true)
    @NotNull
    @Min(0)
    private Integer usedTime;

    @ApiModelProperty(name = "answerResult", value = "答题结果（1：答对，2：答错）", required = true)
    @NotNull
    @Min(1)
    @Max(2)
    private Integer answerResult;

    public String getGameRespondentId() {
        return gameRespondentId;
    }

    public void setGameRespondentId(String gameRespondentId) {
        this.gameRespondentId = gameRespondentId;
    }

    public Integer getModuleCode() {
        return moduleCode;
    }

    public void setModuleCode(Integer moduleCode) {
        this.moduleCode = moduleCode;
    }

    public Integer getQuestionCode() {
        return questionCode;
    }

    public void setQuestionCode(Integer questionCode) {
        this.questionCode = questionCode;
    }

    public Integer getUsedTime() {
        return usedTime;
    }

    public void setUsedTime(Integer usedTime) {
        if (usedTime != null) {
            usedTime = usedTime < MAX_USED_TIME ? usedTime : MAX_USED_TIME;
        }
        this.usedTime = usedTime;
    }

    public Integer getAnswerResult() {
        return answerResult;
    }

    public void setAnswerResult(Integer answerResult) {
        this.answerResult = answerResult;
    }
}
