package com.kospo.talk.payload;

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

import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;

/**
 * DTO for {@link com.kospo.talk.model.PersonAutoReply}
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(name = "PersonAutoReplyDto", description = "개인 자동 응답")
public class PersonAutoReplyDto implements Serializable {
    @Schema(name = "id", description = "아이디")
    int id;
    @Schema(name = "sabun", description = "사번")
    String sabun;
    @Schema(name = "workId", description = "업무아이디")
    String workId;
    @Size(max = 200)
    @Schema(name = "content", description = "내용")
    String content;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS", timezone = "Asia/Seoul")
    @Schema(name = "insDate", description = "등록일")
    private LocalDateTime insDate;

    public static PersonAutoReplyDto to(PersonAutoReply personAutoReply) {
        return PersonAutoReplyDto.builder()
                .id(personAutoReply.getId())
                .sabun(personAutoReply.getSabun())
                .workId(personAutoReply.getWorkId())
                .content(personAutoReply.getContent())
                .insDate(personAutoReply.getInsDate()).build();
    }
}