package com.kospo.talk.model;

import com.kospo.talk.payload.TalkReadDto;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.*;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "talk_read")
public class TalkRead {
    @EmbeddedId
    private TalkReadId id;

    @Column(name = "read_yn")
    private Boolean readYn;

    public static TalkRead to(TalkReadDto talkReadDto) {
        return TalkRead.builder()
                .id(TalkReadId.builder().talkId(talkReadDto.getTalkId()).sabun(talkReadDto.getSabun()).insDate(talkReadDto.getInsDate()).build())
                .readYn(talkReadDto.getReadYn()).build();
    }

}