package cn.reghao.tnb.file.app.zoss.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.oss.api.dto.disk.DiskVolume;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

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

/**
 * @author reghao
 * @date 2024-03-04 17:08:20
 */
@NoArgsConstructor
@AllArgsConstructor
@Setter
@Getter
public class StoreVolume extends BaseObject<Integer> {
    @NotBlank
    private String storeDir;
    @NotNull
    private Integer storeNodeId;
    @NotBlank
    private String name;
    @NotBlank
    private String volume;
    @NotBlank
    private String mountPoint;
    @NotBlank
    private String fsType;
    @NotBlank
    private String blockId;
    @NotNull
    private Long totalSpace;
    @NotNull
    private Long availSpace;
    @NotNull
    private Long totalInode;
    @NotNull
    private Long availInode;

    private String usedSpaceStr;
    private double percentSpace;
    private long usedInode;
    private double percentInode;

    public StoreVolume(int storeNodeId, DiskVolume diskVolume) {
        this.storeDir = diskVolume.getStoreDir();
        this.storeNodeId = storeNodeId;
        this.name = diskVolume.getName();
        this.volume = diskVolume.getVolume();
        this.mountPoint = diskVolume.getMountPoint();
        this.fsType = diskVolume.getFsType();
        this.blockId = diskVolume.getBlockId();
        this.totalSpace = diskVolume.getTotalSpace();
        this.availSpace = diskVolume.getAvailSpace();
        this.totalInode = diskVolume.getTotalInode();
        this.availInode = diskVolume.getAvailInode();
    }
}
