package com.microservices.file.domain.vo.response;

import com.microservices.file.domain.vo.CheckInstantUploadVo;
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 CheckInstantUploadResponseVo implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

    @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("已存在未上传完成的上传状态,UPLOADING-上传中，MERGING-合并中（断点续传时）")
    private String resumingUploadStatus;

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

    public static CheckInstantUploadResponseVo from(CheckInstantUploadVo vo) {
        CheckInstantUploadResponseVo response = new CheckInstantUploadResponseVo();
        response.setCanInstantUpload(vo.getCanInstantUpload());
        response.setCanResumingUpload(vo.getCanResumingUpload());
        response.setExistingFileId(vo.getExistingFileId());
        response.setExistingFileName(vo.getExistingFileName());
        response.setExistingFilePath(vo.getExistingFilePath());
        response.setExistingFileUrl(vo.getExistingFileUrl());
        response.setExistingFileSize(vo.getExistingFileSize());
        response.setResumingUploadId(vo.getResumingUploadId());
        response.setCompletedUploadChunkedNumberList(vo.getCompletedUploadChunkedNumberList());
        response.setResumingUploadStatus(vo.getResumingUploadStatus());
        response.setMessage(vo.getMessage());
        return response;
    }
}
