<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.icomsys.main_vm.db.mybatis.mapper.NlpWisenutApiMapper">

    <!-- 프로젝트ID 조회 -->
    <select id="selectProjectId" resultType="long">
        /* NlpWisenutApiMapper.selectProjectId */
        SELECT A.IF_MAPPING_ID
        FROM TB_PROJECT_SETTING A
        WHERE A.OPR_MNG_CODE = #{serviceCode}
    </select>

    <!-- 프로젝트ID 조회 -->
    <select id="selectProjectIdforOprMngCode" resultType="long">
        /* NlpWisenutApiMapper.selectProjectId */
        SELECT A.IF_MAPPING_ID
        FROM TB_PROJECT_SETTING A
        WHERE A.OPR_MNG_CODE = #{oprMngCode}
    </select>

    <select id="selectProjectName" resultType="java.util.HashMap">
        /* NlpWisenutApiMapper.selectProjectName */
        SELECT OPR_MNG_NAME
        FROM TB_ICS_OPR_MNG_INFO
        WHERE OPR_MNG_CODE = #{serviceCode}
    </select>

    <!-- 인텐트ID 조회 -->
    <select id="selectIntentId" resultType="long">
        /* NlpWisenutApiMapper.selectIntentId */
        SELECT A.IF_MAPPING_ID
        FROM TB_INTENT_MASTER A
        WHERE A.SEQ = #{seq}
    </select>

    <!-- 인텐트ID 조회 + 프로젝트ID조회 -->
    <select id="selectIntentIdForDelete" resultType="java.util.HashMap">
        /* NlpWisenutApiMapper.selectIntentIdForDelete */
        SELECT A.IF_MAPPING_ID AS intentId, B.IF_MAPPING_ID AS projectId
        FROM TB_INTENT_MASTER A
        JOIN TB_PROJECT_SETTING B
        ON A.OPR_MNG_CODE = B.OPR_MNG_CODE
        WHERE A.SEQ =
        <choose>
            <when test="seq == null or seq == ''">
                (SELECT IFNULL(MAX(SEQ), 0) FROM TB_INTENT_MASTER)
            </when>
            <otherwise>
                #{seq}
            </otherwise>
        </choose>
    </select>

    <!-- 질의문ID 조회 -->
    <select id="selectIntentSentenctId" resultType="long">
        /* NlpWisenutApiMapper.selectIntentSentenctId */
        SELECT A.IF_MAPPING_ID
        FROM TB_INTENT_EXAMPLE A
        WHERE A.SEQ = #{seq}
    </select>

    <!-- 질의문ID 조회 + 프로젝트ID조회-->
    <select id="selectIntentSentenctIdforDelete" resultType="java.util.HashMap">
        /* NlpWisenutApiMapper.selectIntentSentenctIdforDelete */
        SELECT A.IF_MAPPING_ID AS sentenceId, C.IF_MAPPING_ID AS projectId
        FROM TB_INTENT_EXAMPLE A
        JOIN TB_INTENT_MASTER B
        ON A.INTENT_SEQ = B.SEQ
        JOIN TB_PROJECT_SETTING C
        ON B.OPR_MNG_CODE = C.OPR_MNG_CODE
        WHERE A.SEQ = #{seq}
    </select>


    <!-- 엔티티ID 조회 -->
    <select id="selectEntityId" resultType="long">
        /* NlpWisenutApiMapper.selectEntityId */
        SELECT A.IF_MAPPING_ID
        FROM TB_SYNONYM_MASTER A
        WHERE A.SEQ = #{seq}
    </select>

    <!-- 엔티티ID 조회 + 프로젝트ID조회-->
    <select id="selectEntityIdForDelete" resultType="java.util.HashMap">
        /* NlpWisenutApiMapper.selectEntityIdForDelete */
        SELECT A.IF_MAPPING_ID AS entityId, B.IF_MAPPING_ID AS projectId
        FROM TB_SYNONYM_MASTER A
            JOIN TB_PROJECT_SETTING B
            ON A.OPR_MNG_CODE = B.OPR_MNG_CODE
        WHERE A.SEQ = #{seq}
    </select>

    <!-- 사전ID 조회 -->
    <select id="selectDictionaryId" resultType="long">
        /* NlpWisenutApiMapper.selectDictionaryId */
        SELECT A.IF_MAPPING_ID
        FROM TB_DICTIONARY_MASTER A
        WHERE A.SEQ = #{seq}
    </select>

    <!-- 사전ID 조회 + 프로젝트ID조회-->
    <select id="selectDictionaryIdforDelete" resultType="java.util.HashMap">
        /* NlpWisenutApiMapper.selectDictionaryIdforDelete */
        SELECT A.IF_MAPPING_ID AS dictionaryId, B.IF_MAPPING_ID AS projectId
        FROM TB_DICTIONARY_MASTER A
            JOIN TB_PROJECT_SETTING B
            ON A.OPR_MNG_CODE = B.OPR_MNG_CODE
        WHERE A.SEQ = #{seq}
    </select>

</mapper>