package cn.reghao.tnb.oss.store.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.oss.api.rest.UploadFilePart;
import lombok.Getter;
import lombok.NoArgsConstructor;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 文件的每一个分片
 *
 * @author reghao
 * @date 2024-10-24 16:33:24
 */
@NoArgsConstructor
@Getter
public class FilePart extends BaseObject<Integer> {
    @NotBlank
    @Size(max = 255)
    private String contentId;
    @NotNull
    private Integer chunkNumber;
    @NotNull
    private Integer currentChunkSize;

    public FilePart(String contentId, UploadFilePart uploadFilePart) {
        this.contentId = contentId;
        this.chunkNumber = uploadFilePart.getChunkNumber();
        this.currentChunkSize = uploadFilePart.getCurrentChunkSize();
    }
}
