package me.qwq.doghouse.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

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.baomidou.mybatisplus.extension.activerecord.Model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import me.qwq.doghouse.enums.MailTaskStatusEnum;
import me.qwq.doghouse.enums.MailTaskTypeEnum;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("mail_task")
public class MailTask extends Model<MailTask> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 邮件任务 ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 邮件任务类型
     */
    @TableField("task_type")
    private MailTaskTypeEnum taskType;

    /**
     * 关联评论 ID
     */
    @TableField("comment_id")
    private Long commentId;

    /**
     * 收件人邮箱地址
     */
    @TableField("recipient")
    private String recipient;

    /**
     * 邮件任务状态
     */
    @TableField("status")
    private MailTaskStatusEnum status = MailTaskStatusEnum.PENDING;

    /**
     * 计划发送时间
     */
    @TableField("send_after")
    private LocalDateTime sendAfter;

    /**
     * 已尝试发送次数
     */
    @TableField("attempts")
    private Integer attempts = 0;

    /**
     * 最近一次发送失败原因
     */
    @TableField("last_error")
    private String lastError;

    /**
     * 任务创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 任务更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;
}
