package com.erp.file.dto;

import com.erp.file.entity.FileEntity;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 文件响应DTO
 */
@Data
public class FileResponse {
    
    private Long id;
    private Long userId;
    private String originalName;
    private String storageName;
    private String path;
    private String url;
    private String mimeType;
    private Long size;
    private String sizeFormatted;
    private String extension;
    private String disk;
    private String module;
    private String purpose;
    private String description;
    private String status;
    private String icon;
    private Boolean exists;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    /**
     * 从实体转换
     */
    public static FileResponse fromEntity(FileEntity entity, boolean exists) {
        FileResponse response = new FileResponse();
        response.setId(entity.getId());
        response.setUserId(entity.getUserId());
        response.setOriginalName(entity.getOriginalName());
        response.setStorageName(entity.getStorageName());
        response.setPath(entity.getPath());
        response.setUrl(entity.getUrl());
        response.setMimeType(entity.getMimeType());
        response.setSize(entity.getSize());
        response.setSizeFormatted(entity.getSizeFormatted());
        response.setExtension(entity.getExtension());
        response.setDisk(entity.getDisk());
        response.setModule(entity.getModule());
        response.setPurpose(entity.getPurpose());
        response.setDescription(entity.getDescription());
        response.setStatus(entity.getStatus());
        response.setIcon(entity.getIcon());
        response.setExists(exists);
        response.setCreatedAt(entity.getCreatedAt());
        response.setUpdatedAt(entity.getUpdatedAt());
        return response;
    }
}
