package com.bailuntec.domain.entity;

import lombok.Data;

import java.time.LocalDateTime;

@Data
public class JobPointLog {
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.id
     *
     * @mbg.generated
     */
    private Integer id;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.job_name
     *
     * @mbg.generated
     */
    private String jobName;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.page_index
     *
     * @mbg.generated
     */
    private Integer pageIndex;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.page_size
     *
     * @mbg.generated
     */
    private Integer pageSize;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.type
     *
     * @mbg.generated
     */
    private Integer type;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.interval_time
     *
     * @mbg.generated
     */
    private Integer intervalTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.start_time
     *
     * @mbg.generated
     */
    private LocalDateTime startTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.end_time
     *
     * @mbg.generated
     */
    private LocalDateTime endTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.gmt_create
     *
     * @mbg.generated
     */
    private LocalDateTime gmtCreate;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column job_point_log.gmt_modified
     *
     * @mbg.generated
     */
    private LocalDateTime gmtModified;


    /**
     * <p>
     * 获取下次运行时间结束时间
     * </p>
     *
     * @param execTime 本次任务执行的时间
     * @return 下次运行时间结束时间
     */
    public LocalDateTime nextEndTime(LocalDateTime execTime) {
        return this.getEndTime().plusDays(this.getIntervalTime()).isAfter(execTime)
                ? execTime
                : this.getEndTime().plusDays(this.getIntervalTime());

    }


    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table job_point_log
     *
     * @mbg.generated
     */
    @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(", jobName=").append(jobName);
        sb.append(", pageIndex=").append(pageIndex);
        sb.append(", pageSize=").append(pageSize);
        sb.append(", type=").append(type);
        sb.append(", intervalTime=").append(intervalTime);
        sb.append(", startTime=").append(startTime);
        sb.append(", endTime=").append(endTime);
        sb.append(", gmtCreate=").append(gmtCreate);
        sb.append(", gmtModified=").append(gmtModified);
        sb.append("]");
        return sb.toString();
    }

    public JobPointLog() {
    }

    public JobPointLog(String jobName, Integer pageIndex, Integer pageSize, Integer type, Integer intervalTime, LocalDateTime startTime, LocalDateTime endTime) {
        this.jobName = jobName;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.type = type;
        this.intervalTime = intervalTime;
        this.startTime = startTime;
        this.endTime = endTime;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table job_point_log
     *
     * @mbg.generated
     */
    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        JobPointLog other = (JobPointLog) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getJobName() == null ? other.getJobName() == null : this.getJobName().equals(other.getJobName()))
                && (this.getPageIndex() == null ? other.getPageIndex() == null : this.getPageIndex().equals(other.getPageIndex()))
                && (this.getPageSize() == null ? other.getPageSize() == null : this.getPageSize().equals(other.getPageSize()))
                && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
                && (this.getIntervalTime() == null ? other.getIntervalTime() == null : this.getIntervalTime().equals(other.getIntervalTime()))
                && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
                && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
                && (this.getGmtCreate() == null ? other.getGmtCreate() == null : this.getGmtCreate().equals(other.getGmtCreate()))
                && (this.getGmtModified() == null ? other.getGmtModified() == null : this.getGmtModified().equals(other.getGmtModified()));
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table job_point_log
     *
     * @mbg.generated
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getJobName() == null) ? 0 : getJobName().hashCode());
        result = prime * result + ((getPageIndex() == null) ? 0 : getPageIndex().hashCode());
        result = prime * result + ((getPageSize() == null) ? 0 : getPageSize().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getIntervalTime() == null) ? 0 : getIntervalTime().hashCode());
        result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
        result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
        result = prime * result + ((getGmtCreate() == null) ? 0 : getGmtCreate().hashCode());
        result = prime * result + ((getGmtModified() == null) ? 0 : getGmtModified().hashCode());
        return result;
    }
}
