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

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

import java.io.Serializable;

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

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("分片序号")
    private Integer chunkNumber;

    @ApiModelProperty("是否上传成功")
    private Boolean success;

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

    /**
     * 创建成功响应
     */
    public static UploadChunkResponseVo success(Integer chunkNumber) {
        UploadChunkResponseVo response = new UploadChunkResponseVo();
        response.setChunkNumber(chunkNumber);
        response.setSuccess(true);
        response.setMessage("分片上传成功");
        return response;
    }

    /**
     * 创建失败响应
     */
    public static UploadChunkResponseVo failed(Integer chunkNumber, String message) {
        UploadChunkResponseVo response = new UploadChunkResponseVo();
        response.setChunkNumber(chunkNumber);
        response.setSuccess(false);
        response.setMessage(message);
        return response;
    }
}
