package com.changfa.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 文件表
 * </p>
 *
 * @author wwz
 * @since 2022-11-04
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_file_data")
@ApiModel(value="FileData对象", description="文件表")
public class FileData extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id主键")
    @TableId(value = "id", type = IdType.INPUT)
    private String id;

    @ApiModelProperty(value = "文件地址")
    @TableField("file_url")
    private String fileUrl;

    @ApiModelProperty(value = "文件所在路径")
    @TableField("file_path")
    private String filePath;

    @ApiModelProperty(value = "文件大小")
    @TableField("file_size")
    private long fileSize;

    @ApiModelProperty(value = "文件后缀")
    @TableField("file_extension")
    private String fileExtension;

    @ApiModelProperty(value = "文件名称")
    @TableField("file_name")
    private String fileName;

    @ApiModelProperty(value = "文件原始名称")
    @TableField("origin_file_name")
    private String originFileName;

    @ApiModelProperty(value = "文件下载路径")
    @TableField("download_path")
    private String downloadPath;

    @ApiModelProperty(value = ":未删除，1：已删除")
    @TableLogic
    private Integer logicDel;


    public FileData(){
    }

    public FileData(String fileUrl, long fileSize, String fileExtension, String fileName, String originFileName, String filePath, String downloadPath, String bucketName){
        this.fileUrl = fileUrl;
        this.id = fileName;
        this.fileSize = fileSize;
        this.fileExtension = fileExtension;
        this.downloadPath = downloadPath;
        this.fileName = fileName;
        this.originFileName = originFileName;
        this.filePath = (filePath.concat("/"+bucketName).concat("/").concat(fileName+fileExtension)).replace("//","/");
        this.fillCreated();
    }

    public static void main(String[] args){
        System.out.println("Iot监狱运维架构图.jpg".substring(0,"Iot监狱运维架构图.jpg".lastIndexOf(".")));
    }

}
