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

    <resultMap id="login" type="LoginVO">
        <result property="userId" column="USER_ID"/>
        <result property="userName" column="USER_NAME"/>
        <result property="eMail" column="E_MAIL"/>
        <result property="password" column="PASSWORD"/>
        <result property="siteCode" column="SITE_CODE"/>
        <result property="systemUserId" column="SYSTEM_USER_ID"/>
        <result property="authCode" column="AUTH_CODE"/>
        <result property="loginCheck" column="LOGIN_CHECK"/>
    </resultMap>

    <select id="TestMapper1" parameterType="String" resultType="String">

        SELECT USER_NAME
        from TB_BOT_USER
        WHERE USER_ID = 'uplus'

    </select>


    <resultMap id="MonitoringScenarioBreakP" type="MonitoringScenarioBreakVO">
        <result property="seq" column="SEQ"/>
        <result property="token" column="TOKEN"/>
        <result property="talkSeq" column="TALK_SEQ"/>
        <result property="oprMngCode" column="OPR_MNG_CODE"/>
        <result property="scenatioSeq" column="SCENARIO_SEQ"/>
        <result property="scenarioName" column="SCENARIO_NAME"/>
        <result property="scenarioResultCode" column="SCENARIO_RESULT_CODE"/>
        <result property="nodeSeq" column="NODE_SEQ"/>
        <result property="nodeName" column="NODE_NAME"/>
        <result property="nodeType" column="NODE_TYPE"/>
        <result property="registDate" column="REGIST_DATE"/>
        <result property="inChannelType" column="IN_CHANNEL_TYPE"/>
        <result property="callId" column="CALL_ID"/>
        <result property="telNo" column="TEL_NO"/>
        <result property="dnisNo" column="DNIS_NO"/>
        <result property="callInitDate" column="CALL_INIT_DATE"/>
        <result property="callEndDate" column="CALL_END_DATE"/>
        <result property="callTime" column="CALL_TIME"/>
        <result property="callEndType" column="CALL_END_TYPE"/>
        <result property="callEndReason" column="CALL_END_REASON"/>
    </resultMap>

    <select id="MonitoringScenarioBreak" resultType="com.icomsys.main_vm.db.mybatis.alias.MonitoringScenarioBreakVO">
        SELECT Z.SEQ                  AS seq
             , Z.TOKEN                AS token
             , Z.TALK_SEQ             AS talkSeq
             , Z.OPR_MNG_CODE         AS oprMngCode
             , Z.SCENARIO_SEQ         AS scenarioSeq
             , Z.RELEASE_SEQ          AS releaseSeq
             , Z.SCENARIO_NAME        AS scenarioName
             , Z.SCENARIO_RESULT_CODE AS scenarioResultCode
        FROM TB_SCENARIO_BREAK_NODE Z
                 inner JOIN TB_CALL_INFO Y
                            ON Y.TOKEN = Z.TOKEN
        WHERE true
          AND Y.CALL_INIT_DATE BETWEEN DATE_FORMAT('2023-02-06', '%Y-%m-%d') AND DATE_FORMAT('2023-02-08', '%Y-%m-%d')
    </select>


    <select id="idLoginFailCheck11" resultMap="login" resultType="LoginVO" parameterType="LoginVO">
        /* LoginVO.idLoginFailCheck */
        SELECT USER_ID
             , USER_NAME
             , PASSWORD
             , E_MAIL
             , CUST_CODE AS SITE_CODE
             , SYSTEM_USER_ID
             , AUTH_CODE
             , LOGIN_CHECK
        FROM TB_BOT_USER
        WHERE USER_ID = #{userId}
          AND USE_FLAG = 'Y'
          AND SOLUTION_CODE = 'VM'
    </select>

    <select id="getUserPolicy" resultType="java.util.HashMap">
        select tsgp.POLICY_VAL
        from TB_USER_AUTH_GROUP tuag
                 inner join TB_SERVICE_GROUP_POLICY tsgp on tuag.AUTH_GROUP_SEQ = tsgp.AUTH_GROUP_SEQ
                 INNER JOIN TB_SERVICE_GROUP tsg on tuag.SERVICE_GROUP = tsg.SERVICE_GROUP_UPPER
        where tuag.USER_SEQ = #{seq}
          and tsg.SERVICE_GROUP_UPPER = #{lastService}
        GROUP BY tsgp.POLICY_VAL
    </select>

</mapper>