package cn.reghao.oss.console.account.model.po;

import cn.reghao.oss.console.util.db.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;

/**
 * @author reghao
 * @date 2023-11-11 00:06:21
 */
@NoArgsConstructor
@AllArgsConstructor
@Setter
@Getter
@Entity
public class DiskFile extends BaseEntity {
    @Column(nullable = false, unique = true)
    private String objectName;
    @Column(nullable = false, unique = true)
    private String objectId;
    @Column(nullable = false)
    private String absolutePath;
    @Column(nullable = false)
    private String sha256sum;
    @Column(nullable = false)
    private String filename;
    @Column(nullable = false)
    private String contentType;
    @Column(nullable = false)
    private Long size;
    private Long owner;

    public DiskFile(String objectName, String objectId, DiskFile diskFile, String filename) {
        this.objectName = objectName;
        this.objectId = objectId;
        this.absolutePath = diskFile.getAbsolutePath();
        this.sha256sum = diskFile.getSha256sum();
        this.filename = filename;
        this.contentType = diskFile.getContentType();
        this.size = diskFile.getSize();
    }

    public DiskFile(String objectName, String objectId, String absolutePath, String sha256sum, String filename, String contentType, long size) {
        this.objectName = objectName;
        this.objectId = objectId;
        this.absolutePath = absolutePath;
        this.sha256sum = sha256sum;
        this.filename = filename;
        this.contentType = contentType;
        this.size = size;
    }
}
