package com.kospo.talk.payload;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.kospo.talk.model.Manual;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.validation.constraints.Size;
import lombok.*;

import java.time.LocalDateTime;
import java.util.Date;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(name = "ManualDto", description = "매뉴얼관리")
public class ManualDto {
    @Schema(name = "workId", description = "업무아이디")
    private String workId;
    @Schema(name = "version", description = "버전관리")
    private String version;
    @Schema(name = "type", description = "파일종류")
    private String type;
    @Schema(name = "onm", description = "논리명")
    private String onm;
    @Schema(name = "vnm", description = "물리명")
    private String vnm;
    @Schema(name = "path", description = "경로")
    private String path;
    @Schema(name = "insDate", description = "등록일")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS", timezone = "Asia/Seoul")
    private LocalDateTime insDate;
    @Schema(name = "deleteYn", description = "삭제여부")
    private Boolean deleteYn;
    @Schema(name = "size", description = "파일사이즈")
    private Integer size;
    @Schema(name = "data", description = "업로드 바이너리 데이터")
    private byte[] data;

    public static ManualDto to(Manual manual) {
        return ManualDto.builder()
                .workId(manual.getId().getWorkId())
                .version(manual.getVersion())
                .type(manual.getType())
                .onm(manual.getOnm())
                .vnm(manual.getId().getVnm())
                .deleteYn(manual.getDeleteYn())
                .size(manual.getSize())
                .insDate(manual.getInsDate()).build();
    }
}
