package com.kospo.talk.payload;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.kospo.talk.model.AutoReply;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(name = "AutoReplyDto", description = "자동응답관리")
public class AutoReplyDto {
    @Schema(name = "workId", description = "업무아이디")
    private String workId;

    @Schema(name = "type", description = "자동응답 타입")
    private String type;

    @Schema(name = "content", description = "내용")
    private String content;

    @Schema(name = "insDate", description = "등록일시")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS", timezone = "Asia/Seoul")
    private LocalDateTime insDate;

    @Schema(name = "insSabun", description = "등록자")
    private String insSabun;

    @Schema(name = "insName", description = "등록자명")
    private String insName;


    public static AutoReplyDto to(AutoReply autoReply) {
        return AutoReplyDto.builder()
                .workId(autoReply.getId().getWorkId())
                .type(autoReply.getId().getType())
                .content(autoReply.getContent())
                .insSabun(autoReply.getInsSabun())
                .insName(autoReply.getInsName())
                .insDate(autoReply.getInsDate())
                .build();
    }

}
