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

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

import java.io.Serializable;

/**
 * 合并分片响应
 *
 * @author microservices
 */
@Data
@ApiModel("合并分片响应")
public class MergeChunksResponseVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("文件下载地址")
    private String url;

    @ApiModelProperty("文件标识")
    private String fileIdentifier;

    @ApiModelProperty("文件路径")
    private String fileName;

    @ApiModelProperty("文件ID")
    private Long fileId;

    @ApiModelProperty("文件原始名称")
    private String fileOriginName;

    @ApiModelProperty("文件后缀")
    private String fileSuffix;

    @ApiModelProperty("文件大小")
    private String fileSize;

    /**
     * 从SysFileInfo转换
     */
    public static MergeChunksResponseVo from(SysFileInfo fileInfo) {
        MergeChunksResponseVo response = new MergeChunksResponseVo();
        response.setUrl(fileInfo.getDownloadUrl());
        response.setFileIdentifier(fileInfo.getFileIdentifier());
        response.setFileName(fileInfo.getFilePath());
        response.setFileId(fileInfo.getFileId());
        response.setFileOriginName(fileInfo.getFileOriginName());
        response.setFileSuffix(fileInfo.getFileSuffix());
        response.setFileSize(fileInfo.getFileSizeInfo());
        return response;
    }
}
