package org.springblade.file.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * @author zhaowei
 * @date 2024/8/23
 */

@Data
@TableName("blade_file_task")
@Schema(description = "文件上传任务对象")
public class FileTask implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description = "主键id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    /**
     *  Md5
     */
    @Schema(description = "Md5")
    private String md5;

    /**
     *  OBS objectKey
     */
    @Schema(description = "OBS objectKey")
    private String objectKey;

    /**
     * 附件名
     */
    @Schema(description = "附件名")
    private String attachmentName;

    /**
     * 文件类型
     */
    @Schema(description = "文件类型")
    private String suffix;

    /**
     * 附件大小(单位:B)
     */
    @Schema(description = "附件大小(单位:B)")
    private Long size;

    /**
     *  分段大小
     */
    @Schema(description = "分段大小")
    private Integer chunkSize;

    /**
     *  分段数量
     */
    @Schema(description = "分段数量")
    private Integer chunkTotal;

    /**
     *  当前分段的位置(已上传完成的分段)，从0开始，上传完第1段，为1
     */
    @Schema(description = "当前分段的位置(已上传完成的分段)，从0开始，上传完第1段，为1")
    private Integer currentIndex;

    /**
     *  华为云初始化上传任务生成的uploadId
     */
    @Schema(description = "华为云初始化上传任务生成的uploadId")
    private String uploadId;

    /**
     * 状态 uploading:正在上传  completed：上传完成 failed：上传失败 paused：已暂停
     */
    @Schema(description = "状态 uploading:正在上传  completed：上传完成 failed：上传失败 paused：已暂停")
    private String status;

    /**
     * 创建人-用户名称
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description = "创建人-用户名称")
    @TableField(fill = FieldFill.INSERT)
    private String createUserName;

    /**
     * 创建人
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description = "创建人")
    @TableField(fill = FieldFill.INSERT)
    private Long createUser;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新人-用户名称
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description = "创建人-用户名称")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateUserName;

    /**
     * 更新人
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description = "更新人")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;

    /**
     * 更新时间
     */
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 状态[0:未删除,1:删除]
     */
    @TableLogic
    @Schema(description = "是否已删除 [0:未删除,1:删除]")
    @TableField(fill = FieldFill.INSERT)
    private Integer isDeleted;

}
