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


import com.icomsys.main_vm.db.jpa.entity.monitoring.id.TbCallInfoId;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicUpdate;

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

@Table(name = "TB_CALL_INFO")
@Entity
@Getter
@Setter
@NoArgsConstructor
@DynamicUpdate
@IdClass(TbCallInfoId.class)
public class TbCallInfo {

    @Id
    @Column(name = "TOKEN", nullable = false, length = 44)
    private String token;

    @Column(name = "OPR_MNG_CODE", nullable = false, length = 100)
    private String oprMngCode;

    @Column(name = "IN_CHANNEL_TYPE", nullable = false, length = 5)
    private String inChannelType;

    @Id
    @Column(name = "CALL_ID", nullable = false, length = 100)
    private String callId;

    @Column(name = "TEL_NO", nullable = false, length = 20)
    private String telNo;

    @Column(name = "DNIS_NO", nullable = false, length = 20)
    private String dnisNo;

    @Column(name = "CALL_INIT_DATE", nullable = true)
    private LocalDateTime callInitDate;

    @Column(name = "CALL_END_DATE", nullable = false)
    private LocalDateTime callEndDate;

    @Column(name = "CALL_TIME", nullable = false)
    private int callTime;

    @Column(name = "CALL_END_TYPE", nullable = false, length = 20)
    private String callEndType;

    @Column(name = "CALL_END_CONVERSION", nullable = true, length = 20)
    private String callEndConversion;

//    USER_REQ : 사용자 요청
//    SCENARIO : 시나리오 흐름
//    INIT_END : 인입 후 끊음
//    SILENT_FB : 묵음 폴백
//    SPEAK_FB : 발화 폴백
//    USER_END : 고객 끊음
    @Column(name = "CALL_END_REASON", nullable = false, length = 20)
    private String callEndReason;

    @Builder
    public TbCallInfo(String token, String oprMngCode, String inChannelType, String callId, String telNo, String dnisNo, LocalDateTime callInitDate, LocalDateTime callEndDate, int callTime, String callEndType, String callEndConversion, String callEndReason) {
        this.token = token;
        this.oprMngCode = oprMngCode;
        this.inChannelType = inChannelType;
        this.callId = callId;
        this.telNo = telNo;
        this.dnisNo = dnisNo;
        this.callInitDate = callInitDate;
        this.callEndDate = callEndDate;
        this.callTime = callTime;
        this.callEndType = callEndType;
        this.callEndConversion = callEndConversion;
        this.callEndReason = callEndReason;
    }


}
