package com.ynfy.buss.exam.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ynfy.buss.exam.question.dto.QuestionDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * @Description: repository
 * @Author: jeecg-boot
 * @Date: 2023-02-22
 * @Version: V1.0
 */
@Data
@TableName("repository")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "repository对象", description = "repository")
public class Repository implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "id")
    private String id;
    /**
     * 题库名称
     */
    @Excel(name = "题库名称", width = 15)
    @ApiModelProperty(value = "题库名称")
    private String title;

    /**
     * 题库编码
     */
    @Excel(name = "题库编码", width = 15)
    private String code;

    /**
     * 题库备注
     */
    @Excel(name = "题库备注", width = 15)
    @ApiModelProperty(value = "题库备注")
    private String remark;
    /**
     * createTime
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "createTime")
    private Date createTime;
    /**
     * updateTime
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "updateTime")
    private Date updateTime;
    /**
     * createBy
     */
    @ApiModelProperty(value = "createBy")
    private String createBy;
    /**
     * updateBy
     */
    @ApiModelProperty(value = "updateBy")
    private String updateBy;

    /**
     * 题目数量
     */
    @TableField(exist = false)
    private Integer num;

    @TableField(exist = false)
    private List<QuestionDTO> questionDTOList;

    /**
     * 题目备注
     */
    @TableField(exist = false)
    private String questionRemark;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Repository that = (Repository) o;
        return code.equals(that.code);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code);
    }
}
