package com.vote.system.domain;

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.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 活动作品设置表
 *
 * @TableName vote_event_work_settings
 */
@TableName(value = "vote_event_work_settings")
@Data
public class VoteEventWorkSettings implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 活动ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long eventId;

    /**
     * 作品类型
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long workTypeId;

    @JsonSerialize(using = ToStringSerializer.class)
    private String roundsId;


    /**
     * 类型别称
     */
    @Valid
    @Size(max = 255 , message = "表单名称最大不可超过255")
    private String alias;

    /**
     * 作品提交开始日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date submissionStartDate;

    /**
     * 作品提交开始日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date submissionEndDate;

    /**
     * 作品收集表单ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long submissionTemplateId;

    /**
     * 最大提交数量
     */
    private Integer maxSubmissions;


    /**
     * 评选前允许修改
     */
    private Integer allowModificationBeforeEvaluation;

    /**
     *
     */
    private Date createdAt;

    /**
     *
     */
    private Date updatedAt;

    @TableField(exist = false)
    private String workTypeName;

    @TableField(exist = false)
    private List<VoteEventEvaluationRounds> voteEventEvaluationRounds;//评选轮次

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        VoteEventWorkSettings other = (VoteEventWorkSettings) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getEventId() == null ? other.getEventId() == null : this.getEventId().equals(other.getEventId()))
                && (this.getWorkTypeId() == null ? other.getWorkTypeId() == null : this.getWorkTypeId().equals(other.getWorkTypeId()))
                && (this.getAlias() == null ? other.getAlias() == null : this.getAlias().equals(other.getAlias()))
                && (this.getSubmissionStartDate() == null ? other.getSubmissionStartDate() == null : this.getSubmissionStartDate().equals(other.getSubmissionStartDate()))
                && (this.getSubmissionEndDate() == null ? other.getSubmissionEndDate() == null : this.getSubmissionEndDate().equals(other.getSubmissionEndDate()))
                && (this.getSubmissionTemplateId() == null ? other.getSubmissionTemplateId() == null : this.getSubmissionTemplateId().equals(other.getSubmissionTemplateId()))
                && (this.getMaxSubmissions() == null ? other.getMaxSubmissions() == null : this.getMaxSubmissions().equals(other.getMaxSubmissions()))
                && (this.getAllowModificationBeforeEvaluation() == null ? other.getAllowModificationBeforeEvaluation() == null : this.getAllowModificationBeforeEvaluation().equals(other.getAllowModificationBeforeEvaluation()))
                && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
                && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getEventId() == null) ? 0 : getEventId().hashCode());
        result = prime * result + ((getWorkTypeId() == null) ? 0 : getWorkTypeId().hashCode());
        result = prime * result + ((getAlias() == null) ? 0 : getAlias().hashCode());
        result = prime * result + ((getSubmissionStartDate() == null) ? 0 : getSubmissionStartDate().hashCode());
        result = prime * result + ((getSubmissionEndDate() == null) ? 0 : getSubmissionEndDate().hashCode());
        result = prime * result + ((getSubmissionTemplateId() == null) ? 0 : getSubmissionTemplateId().hashCode());
        result = prime * result + ((getMaxSubmissions() == null) ? 0 : getMaxSubmissions().hashCode());
        result = prime * result + ((getAllowModificationBeforeEvaluation() == null) ? 0 : getAllowModificationBeforeEvaluation().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", eventId=").append(eventId);
        sb.append(", workTypeId=").append(workTypeId);
        sb.append(", alias=").append(alias);
        sb.append(", submissionStartDate=").append(submissionStartDate);
        sb.append(", submissionEndDate=").append(submissionEndDate);
        sb.append(", submissionTemplateId=").append(submissionTemplateId);
        sb.append(", maxSubmissions=").append(maxSubmissions);
        sb.append(", allowModificationBeforeEvaluation=").append(allowModificationBeforeEvaluation);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}