package com.example.pdfservice.dto;

import com.example.pdfservice.entity.FileDocument;

import java.time.LocalDateTime;

/**
 * What we expose to the React app. Note we never expose the raw disk path
 * to the client — only an id it can use to call the download/preview endpoints.
 */
public class FileResponse {

    private Long id;
    private String fileName;
    private String contentType;
    private long fileSize;
    private LocalDateTime uploadDate;
    private String downloadUrl;
    private String previewUrl;

    public static FileResponse fromEntity(FileDocument doc) {
        FileResponse dto = new FileResponse();
        dto.id = doc.getId();
        dto.fileName = doc.getOriginalFileName();
        dto.contentType = doc.getContentType();
        dto.fileSize = doc.getFileSize();
        dto.uploadDate = doc.getUploadDate();
        dto.downloadUrl = "/api/files/" + doc.getId() + "/download";
        dto.previewUrl = "/api/files/" + doc.getId() + "/preview";
        return dto;
    }

    public Long getId() {
        return id;
    }

    public String getFileName() {
        return fileName;
    }

    public String getContentType() {
        return contentType;
    }

    public long getFileSize() {
        return fileSize;
    }

    public LocalDateTime getUploadDate() {
        return uploadDate;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public String getPreviewUrl() {
        return previewUrl;
    }
}
