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

import com.microservices.file.domain.vo.InitChunkedUploadVo;
import com.microservices.system.api.domain.SysFileInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * 初始化分片上传响应
 *
 * @author microservices
 */
@Data
@ApiModel("初始化分片上传响应")
public class InitChunkedUploadResponseVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("上传ID")
    private String uploadId;

    @ApiModelProperty("总分片数")
    private Integer totalChunks;

    @ApiModelProperty("分片大小（字节）")
    private Long chunkSize;

    @ApiModelProperty("上传分片的并发数")
    private Integer concurrent;


    @ApiModelProperty("哈希类型(FULL=完整文件MD5, SAMPLE=采样点哈希)")
    private String hashType;

    @ApiModelProperty("采样点分片序号列表")
    private List<Integer> sampleChunks;

    /**
     * 从InitChunkedUploadVo转换
     */
    public static InitChunkedUploadResponseVo from(InitChunkedUploadVo vo) {
        InitChunkedUploadResponseVo response = new InitChunkedUploadResponseVo();
        response.setUploadId(vo.getUploadId());
        response.setTotalChunks(vo.getTotalChunks());
        response.setChunkSize(vo.getChunkSize());
        response.setConcurrent(vo.getConcurrent());
        response.setHashType(vo.getHashType());
        response.setSampleChunks(vo.getSampleChunks());
        return response;
    }
}
