Question.java 4.4 KB
package com.skua.modules.edu.entity;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.skua.core.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;

/**
 * 在线考试-试题
 */
@Data
@TableName("edu_question")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="edu_question对象", description="在线考试-试题")
public class Question {

	/**主键*/
	@TableId(type = IdType.ID_WORKER_STR)
    @ApiModelProperty(value = "主键")
	private String id;
	/**题库编号*/
	@Excel(name = "题库编号", width = 15)
    @ApiModelProperty(value = "题库编号")
	private String questionDbId;
	/**试题标题*/
	@Excel(name = "试题标题", width = 15)
    @ApiModelProperty(value = "试题标题")
	private String questionTitle;
	/**试题类型:1 单选、2多选、3判断*/
	@Excel(name = "试题类型:1 单选、2多选、3判断", width = 15)
    @ApiModelProperty(value = "试题类型:1 单选、2多选、3判断")
	private String questionType;

	/**试题选项Json内容*/
	@Excel(name = "试题选项Json内容", width = 15)
    @ApiModelProperty(value = "试题选项Json内容")
	private String questionData;
	/**试题解析*/
	@Excel(name = "试题解析", width = 15)
    @ApiModelProperty(value = "试题解析")
	private String analyzes;
	/**备注*/
	@Excel(name = "备注", width = 15)
    @ApiModelProperty(value = "备注")
	private String remark;
	/**上传人*/
	@Excel(name = "上传人", width = 15)
	@Dict(dicCode = "id",dictTable = "sys_user",dicText = "realname")
    @ApiModelProperty(value = "上传人")
	private String createBy;

	/**上传时间*/
	@Excel(name = "上传时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "上传时间")
	private Date createTime;
	/**更新人*/
	@Excel(name = "更新人", width = 15)
    @ApiModelProperty(value = "更新人")
	@Dict(dicCode = "id",dictTable = "sys_user",dicText = "realname")
	private String updateBy;
	/**更新时间*/
	@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
	private Date updateTime;
	/**delFlag*/
	@Excel(name = "delFlag", width = 15)
    @ApiModelProperty(value = "delFlag")
	private Integer delFlag;
	/**厂站ID*/
	@Excel(name = "厂站ID", width = 15)
	@ApiModelProperty(value = "厂站ID")
	@Dict(dictTable = "sys_depart", dicCode="id", dicText = "depart_name")
	private String createDept;

	/**试题分值*/
	@TableField(exist=false)
	@Excel(name = "试题分值", width = 15)
	@ApiModelProperty(value = "试题分值")
	private String score;

	@TableField(exist=false)
	@ApiModelProperty(value = "试题选项集合")
	private List<QuestionOption> optionList;

	@Excel(name = "试题答案", width = 15)
	@ApiModelProperty(value = "试题答案")
	private String questionAnswer;

	@TableField(exist=false)
	@Excel(name = "用户答案", width = 15)
	@ApiModelProperty(value = "用户答案")
	private String userAnswer;


	@TableField(exist=false)
	@ApiModelProperty(value = "厂站名称")
	private String departName;

	@TableField(exist=false)
	@ApiModelProperty(value = "用户名称")
	private String userName;

	public List<QuestionOption> getOptionList() {
		if(optionList  == null && StringUtils.isNotEmpty(questionData)){
			// 创建Gson实例
			Gson gson = new Gson();
			Type questionTypeListType = new TypeToken<List<QuestionOption>>() {}.getType();
			optionList = gson.fromJson(questionData,questionTypeListType);
		}
		return optionList;
	}
}