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

import com.icomsys.main_vm.biz.rcp.conversation.vo.SelectSimilarityCriteriaVO;
import com.icomsys.main_vm.db.mybatis.alias.LoginVO;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;
import java.util.Map;

@Table(name = "TB_PROJECT_SETTING")
@Entity
@Getter
@Setter
@NoArgsConstructor
public class TbProjectSetting {
    @Id
    @Column(name = "OPR_MNG_CODE", nullable = false, length = 40)
    private String oprMngCode;
    @Column(name = "SIMILARITY_CRITERIA", nullable = true)
    private double similarityCriteria;
    @Column(name = "CLASS_CRITERIA", nullable = true)
    private double classCriteria;
    @Column(name = "CLASS_RESULT_CRITERIA", nullable = true)
    private double classResultCriteria;
    @Column(name = "FALLBACK_MSG", nullable = true, length = 500)
    private String fallbackMsg;
    @Column(name = "GREETING_MSG", nullable = true, length = 500)
    private String greetingMsg;
    @Column(name = "IF_MAPPING_ID", nullable = true, length = 20)
    private Long ifMappingId;
    @Column(name = "REGIST_ID", nullable = false, length = 30)
    private String registId;
    @Column(name = "REGIST_DATE", nullable = false)
    private LocalDateTime registDate;
    @Column(name = "UPDATE_ID", nullable = true)
    private String updateId;
    @Column(name = "UPDATE_DATE", nullable = true)
    private LocalDateTime updateDate;


    @Builder
    public TbProjectSetting(String oprMngCode, double similarityCriteria, double classCriteria, double classResultCriteria, String fallbackMsg, String greetingMsg, Long ifMappingId, String registId, LocalDateTime registDate, String updateId, LocalDateTime updateDate) {
        this.oprMngCode = oprMngCode;
        this.similarityCriteria = similarityCriteria;
        this.classCriteria = classCriteria;
        this.classResultCriteria = classResultCriteria;
        this.fallbackMsg = fallbackMsg;
        this.greetingMsg = greetingMsg;
        this.ifMappingId = ifMappingId;
        this.registId = registId;
        this.registDate = registDate;
        this.updateId = updateId;
        this.updateDate = updateDate;
    }

    public SelectSimilarityCriteriaVO toSelectSimilarityCriteriaVo() {
        SelectSimilarityCriteriaVO sscv = new SelectSimilarityCriteriaVO();
        sscv.setOprMngCode(this.oprMngCode);
        sscv.setSimilarityCriteria(this.similarityCriteria);
        sscv.setClassResultCriteria(this.classResultCriteria);
        sscv.setFallbackMsg(this.fallbackMsg);
        sscv.setGreetingMsg(this.greetingMsg);
        return sscv;
    }

//    public TbProjectSetting UpdateProject(Map<String, String> dataMap) {
//        this.similarityCriteria = Double.parseDouble(dataMap.get("similarityCriteria"));
//        this.classCriteria = Double.parseDouble(dataMap.get("classCriteria"));
//        this.classResultCriteria = Double.parseDouble(dataMap.get("classResultCriteria"));
//        this.fallbackMsg = dataMap.get("fallbackMsg");
//        this.greetingMsg = dataMap.get("greetingMsg");
//        this.updateId = resultVO.getUserId();
//        this.updateDate = LocalDateTime.now();
//        return this;
//    }
}
