package com.storlead.mail.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.storlead.framework.common.constant.LongToStringSerializer;
import com.storlead.framework.mybatis.entity.SysBaseField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 邮件表
 * </p>
 *
 * @author chenkq
 * @since 2024-05-28
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("emails")
@ApiModel(value="EmailsEntity对象", description="邮件表")
public class EmailsEntity extends SysBaseField {

    private static final long serialVersionUID = 1L;

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

    @TableField("smtp_pop_id")
    private Long smtpPopId;

    @ApiModelProperty(value = "messageId")
    @TableField("message_id")
    private String messageId;

    @ApiModelProperty(value = "主键id")
    @TableField("msg_uid")
    private String msgUid;

    @ApiModelProperty(value = "跟进主键id")
    @TableField("follow_up_id")

    @JsonSerialize(using = LongToStringSerializer.class)
    private Long followUpId;

    @TableField("in_out_mark")
    @ApiModelProperty(value = "进 :1， 出 :2")
    private Integer inOutMark;

    @ApiModelProperty(value = "主题")
    @TableField("subject")
    private String subject;

    @ApiModelProperty(value = "收件人")
    @TableField("recipient")
    private String recipient;

    @ApiModelProperty(value = "收件人")
    @TableField("recipient_name")
    private String recipientName;

    @ApiModelProperty(value = "抄送人邮箱")
    @TableField("recipient_cc")
    private String recipientCc;

    @ApiModelProperty(value = "抄送人邮箱")
    @TableField("recipient_cc_name")
    private String recipientCcName;

    @ApiModelProperty(value = "密送人邮箱")
    @TableField("recipient_bcc")
    private String recipientBcc;

    @ApiModelProperty(value = "密送人")
    @TableField("recipient_bcc_name")
    private String recipientBccName;

    @ApiModelProperty(value = "发件人")
    @TableField("`from`")
    private String from;

    @ApiModelProperty(value = "发件人")
    @TableField("from_name")
    private String fromName;

    @ApiModelProperty(value = "邮件内容")
    @TableField("content")
    private String content;

    @ApiModelProperty(value = "邮件内容")
    @TableField("liaison_ids")
    private String liaisonIds;

    @ApiModelProperty(value = "邮件内容")
    @TableField("customer_ids")
    private String customerIds;

    @ApiModelProperty(value = "分组")
    @TableField("folder")
    private String folder;

    @ApiModelProperty(value = "用户自定义文件夹Id")
    @TableField("custom_folder_id")
    private Long customFolderId;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "收件时间")
    @TableField("recipient_date")
    private Date recipientDate;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "发件时间")
    @TableField("sent_date")
    private Date sentDate;

    @ApiModelProperty(value = "1: 已读,0 :未读")
    @TableField("is_read")
    private Integer isRead;

    @ApiModelProperty(value = "回复邮件id")
    @TableField("reply_msg_id")
    private Long replyMsgId;

    @ApiModelProperty(value = "邮件大小")
    @TableField("email_size")
    private Long emailSize;

    @ApiModelProperty(value = "-1,待发送,0: 发送中，1：发送成功，2：发送失败")
    @TableField("status")
    private Integer status;

    @ApiModelProperty(value = "备注")
    @TableField("remark")
    private String remark;

    @TableField("is_star")
    private Integer isStar;

    @TableField("is_trash")
    private Integer isTrash;

    @ApiModelProperty(value = "是否从邮件服务器删除：0 未删除，1：删除，2：未找到")
    @TableField("delete_tag")
    private Integer deleteTag;

    @TableField(exist = false)
    private List attachments;

    @ApiModelProperty(value = "客户")
    @TableField(exist = false)
    private Object customerVO;

    @ApiModelProperty(value = "文件大小+单位")
    @TableField(exist = false)
    private String emailSizeName;

    @ApiModelProperty(value = "是否需要回执，默认0：不需要，1 需要")
    @TableField("is_receipt")
    private Integer isReceipt;

    @ApiModelProperty(value = "是否需要跟踪，默认0：不需要，1 需要")
    @TableField("is_track")
    private Integer isTrack;

    @ApiModelProperty(value = "是否需要阅读提醒，默认0：不需要，1 需要")
    @TableField("read_remind")
    private Integer readRemind;

    @ApiModelProperty(value = "是否需要阅读提醒，默认0：正常收取邮件，1 导入")
    @TableField("source_type")
    private Integer sourceType;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = "定时发送时间")
    @TableField("delay_send_time")
    private LocalDateTime delaySendTime;

    @ApiModelProperty(value = "是不是只获取了头信息")
    @TableField("is_only_head")
    private Integer isOnlyHead;

    @ApiModelProperty(value = "文件夹名称")
    @TableField(exist = false)
    private String folderName;


    @TableField(exist = false)
    @ApiModelProperty(value = "状态（0未跟进，1已跟进。根据邮件是否关联跟进判定）")
    private Integer followStatus;

    @TableField(exist = false)
    @ApiModelProperty(value = "状态（0未跟进，1已跟进。根据邮件是否关联跟进判定）")
    private List<Object> customerls;

    @TableField(exist = false)
    private Long customerId;

    @ApiModelProperty(value = "跟进时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime followUpTime;

    @ApiModelProperty(value = "客户邮件关联id")
    @TableField(exist = false)
    private Long customerMailId;

    @ApiModelProperty(value = "附件数")
    @TableField(exist = false)
    private Integer attachmentNum;
}
