package com.kospo.talk.model;

import com.kospo.talk.payload.TalkMemberDto;
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_member")
public class TalkMember {
    @EmbeddedId
    private TalkMemberId id;

    @Column(name="name")
    private String name;

    @Column(name="mark_yn")
    private Boolean markYn;

    @Column(name="delete_yn")
    private Boolean deleteYn;

    @Column(name="dummy_yn")
    private Boolean dummyYn;

    public static TalkMember to(TalkMemberDto talkMemberDto) {
        return TalkMember.builder()
                .id(TalkMemberId.builder().talkId(talkMemberDto.getTalkId()).sabun(talkMemberDto.getSabun()).build())
                .name(talkMemberDto.getName())
                .markYn(talkMemberDto.getMarkYn())
                .dummyYn(talkMemberDto.getDummyYn())
                .deleteYn(talkMemberDto.getDeleteYn()).build();
    }
}