package com.icomsys.main_vm.db.jpa.entity.conversation;

import com.icomsys.main_vm.biz.rcp.conversation.dto.TbIntentExampleDto;
import com.icomsys.main_vm.db.jpa.entity.conversation.id.TbIntentExampleId;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.time.LocalDateTime;

@Table(name = "TB_INTENT_EXAMPLE")
@Entity
@Getter
@Setter
@NoArgsConstructor
//@IdClass(TbIntentExampleId.class)
public class TbIntentExample {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "SEQ", nullable = false, length = 20)
    private Long seq;
//    @Id
    @Column(name = "INTENT_SEQ", nullable = false, length = 20)
    private Long intentSeq;
    @Column(name = "EXAMPLE_TEXT", nullable = true, length = 200)
    private String exampleText;
    @Column(name = "IF_MAPPING_ID", nullable = true, length = 20)
    private Long ifMappingId;
    @Column(name = "USE_YN", nullable = true, length = 1)
    private String useYn;
    @Column(name = "REGIST_ID", nullable = false, length = 20)
    private String registId;
    @Column(name = "REGIST_DATE", nullable = false)
    private LocalDateTime registDate;
    @Column(name = "UPDATE_ID", nullable = true, length = 20)
    private String updateId;
    @Column(name = "UPDATE_DATE", nullable = true)
    private LocalDateTime updateDate;

    @Builder
    public TbIntentExample(Long seq, Long intentSeq, String exampleText, Long ifMappingId, String useYn, String registId, LocalDateTime registDate, String updateId, LocalDateTime updateDate) {
        this.seq = seq;
        this.intentSeq = intentSeq;
        this.exampleText = exampleText;
        this.ifMappingId = ifMappingId;
        this.useYn = useYn;
        this.registId = registId;
        this.registDate = registDate;
        this.updateId = updateId;
        this.updateDate = updateDate;
    }

    public TbIntentExampleDto toTbIntentExampleDto() {
        TbIntentExampleDto tied = new TbIntentExampleDto();
        tied.setSeq(this.seq);
        tied.setIntentSeq(this.intentSeq);
        tied.setExampleText(this.exampleText);
        tied.setIfMappingId(this.ifMappingId);
        tied.setUseYn(this.useYn);
        tied.setRegistId(this.registId);
        tied.setRegistDate(this.registDate);
        tied.setUpdateId(this.updateId);
        tied.setUpdateDate(this.updateDate);
        return tied;
    }

}
