package com.microservices.file.domain.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
@ApiModel("检查秒传返回")
public class CheckInstantUploadVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("是否可以秒传")
    private Boolean canInstantUpload = false;

    @ApiModelProperty("是否可以断点续传")
    private Boolean canResumingUpload = false;

    @ApiModelProperty("已存在文件ID（秒传时）")
    private Long existingFileId;

    @ApiModelProperty("已存在文件名（秒传时）")
    private String existingFileName;

    @ApiModelProperty("已存在文件路径（秒传时）")
    private String existingFilePath;

    @ApiModelProperty("已存在文件下载地址（秒传时）")
    private String existingFileUrl;

    @ApiModelProperty("已存在文件大小（秒传时）")
    private String existingFileSize;

    @ApiModelProperty("已存在未上传完成的上传Id（断点续传时）")
    private String resumingUploadId;

    @ApiModelProperty("已上传的分片Id列表（断点续传时）-当状态为合并中时该值为null，请直接调用进度接口查看进度")
    private List<Integer> completedUploadChunkedNumberList;

    @ApiModelProperty("已存在未上传完成的上传状态（断点续传时）")
    private String resumingUploadStatus;

    @ApiModelProperty("消息")
    private String message;

    public static CheckInstantUploadVo instantSuccess(Long fileId, String fileName, String filePath, String fileUrl, String fileSize) {
        CheckInstantUploadVo vo = new CheckInstantUploadVo();
        vo.setCanInstantUpload(true);
        vo.setExistingFileId(fileId);
        vo.setExistingFileName(fileName);
        vo.setExistingFilePath(filePath);
        vo.setExistingFileUrl(fileUrl);
        vo.setExistingFileSize(fileSize);
        vo.setMessage("秒传成功");
        return vo;
    }

    public static CheckInstantUploadVo resumingSuccess(String uploadId, List<Integer> completedUploadChunkedIdList,String resumingUploadStatus) {
        CheckInstantUploadVo vo = new CheckInstantUploadVo();
        vo.setCanResumingUpload(true);
        vo.setResumingUploadId(uploadId);
        vo.setCompletedUploadChunkedNumberList(completedUploadChunkedIdList);
        vo.setResumingUploadStatus(resumingUploadStatus);
        vo.setMessage("断点续传成功");
        return vo;
    }

    public static CheckInstantUploadVo needUpload(String message) {
        CheckInstantUploadVo vo = new CheckInstantUploadVo();
        vo.setCanInstantUpload(false);
        vo.setMessage(message);
        return vo;
    }
}
