package com.bohuikeji.frame.module.admin.entity.vo;

import com.bohuikeji.frame.module.admin.base.SuperBase;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;

/**
 * 文件数据块
 */
@Data
public class FileVo extends SuperBase {
    @ApiModelProperty(value = "文件唯一id")
    String id;
    @ApiModelProperty(value = "地址")
    String url;
    @ApiModelProperty(value = "地址类型(相对地址：PATH，绝对地址：URL)")
    String urlType="PATH";
    @ApiModelProperty(value = "原始名称")
    String originalName;
    @ApiModelProperty(value = "文件大小")
    long size;
    @ApiModelProperty(value = "文件类型")
        String type;
    @ApiModelProperty(value = "上传时间")
    LocalDateTime time;

    public FileVo(){}

    /**
     * 使用MultipartFile初始化
     * @param file
     */
    public FileVo(MultipartFile file,String url){
        this.id="";
        this.url=url;
        this.size=file.getSize();
        this.originalName=file.getOriginalFilename();
        this.size=file.getSize();
        this.time=LocalDateTime.now();
    }
    public FileVo(MultipartFile file,String url,String urlType){
        this(file,url);
        this.urlType=urlType;

    }
}
