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 java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 活动评选轮次表
 *
 * @TableName vote_event_evaluation_rounds
 */
@TableName(value = "vote_event_evaluation_rounds")
@Data
public class VoteEventEvaluationRounds implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 活动ID
     */
    private Long eventId;

    /**
     * 类型：评选轮或评奖轮
     */
    private Object type;

    /**
     * 轮次
     */
    private Integer roundNumber;

    /**
     * 评分规则ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long scoringRuleId;

    /**
     * 评选开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startDate;

    /**
     * 评选结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endDate;

    /**
     * 存储多个评审专家的ID，使用逗号分隔
     */
    private String judges;

    /**
     * 存储多个活动奖项的ID，使用逗号分隔
     */
    private String awards;

    /**
     *
     */
    private Date createdAt;

    /**
     *
     */
    private Date updatedAt;

    @TableField(exist = false)
    private String judgesName; //专家名

    @TableField(exist = false)
    private List<VoteEventAwards> voteEventAwardsList;

    @TableField(exist = false)
    private String ruleName;//规则名


    @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;
        }
        VoteEventEvaluationRounds other = (VoteEventEvaluationRounds) 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.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
                && (this.getRoundNumber() == null ? other.getRoundNumber() == null : this.getRoundNumber().equals(other.getRoundNumber()))
                && (this.getScoringRuleId() == null ? other.getScoringRuleId() == null : this.getScoringRuleId().equals(other.getScoringRuleId()))
                && (this.getStartDate() == null ? other.getStartDate() == null : this.getStartDate().equals(other.getStartDate()))
                && (this.getEndDate() == null ? other.getEndDate() == null : this.getEndDate().equals(other.getEndDate()))
                && (this.getJudges() == null ? other.getJudges() == null : this.getJudges().equals(other.getJudges()))
                && (this.getAwards() == null ? other.getAwards() == null : this.getAwards().equals(other.getAwards()))
                && (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 + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getRoundNumber() == null) ? 0 : getRoundNumber().hashCode());
        result = prime * result + ((getScoringRuleId() == null) ? 0 : getScoringRuleId().hashCode());
        result = prime * result + ((getStartDate() == null) ? 0 : getStartDate().hashCode());
        result = prime * result + ((getEndDate() == null) ? 0 : getEndDate().hashCode());
        result = prime * result + ((getJudges() == null) ? 0 : getJudges().hashCode());
        result = prime * result + ((getAwards() == null) ? 0 : getAwards().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(", type=").append(type);
        sb.append(", roundNumber=").append(roundNumber);
        sb.append(", scoringRuleId=").append(scoringRuleId);
        sb.append(", startDate=").append(startDate);
        sb.append(", endDate=").append(endDate);
        sb.append(", judges=").append(judges);
        sb.append(", awards=").append(awards);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
