package com.kospo.talk.model;

import com.kospo.talk.payload.PersonAutoReplyDto;
import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import lombok.*;

import java.time.Instant;
import java.time.LocalDateTime;

@TableGenerator(
    name = "person_auto_reply_seq",
    table = "sequence",
    pkColumnName = "sequence_name",
    valueColumnName = "next_val",
    allocationSize = 1
)

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "person_auto_reply")
public class PersonAutoReply {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE,generator = "person_auto_reply_seq")
    private Integer id;

    @Column(name = "sabun", length = 10)
    private String sabun;

    @Column(name = "work_id", length = 20)
    private String workId;

    @Column(name = "content", length = 200)
    private String content;

    @Column(name = "ins_date")
    private LocalDateTime insDate;


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