package easydo.technology.quartz.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

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

@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("sys_quartz_job")
public class SysQuartzJob implements Serializable {
    private static final long serialVersionUID = 1L;

    public static final String JOB_KEY = "JOB_KEY";

    @TableId(value = "job_id", type= IdType.AUTO)
    private Long id;

    @TableField(exist = false)
    private String uuid;

    private String beanName;

    private String cronExpression;

    private Boolean isPause;

    private String jobName;

    private String methodName;

    private String params;

    private String description;

    private String personInCharge;

    private String email;

    private String subTask;

    private Boolean pauseAfterFailure;
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    public void copyFrom(SysQuartzJob source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    /* 分组校验 */
    public @interface Create {
    }

    /* 分组校验 */
    public @interface Update {
    }
}
