<?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="cokr.xit.fims.cvlc.dao.WarningWordsMapper">

<select id="selectWarningWordsList" parameterType="cokr.xit.fims.crdn.CrdnQuery" resultType="dataobject">
/* 계도문 문구 설정 목록 가져오기(warningWordsMapper.selectWarningWordsList) */
SELECT A.CODE     AS LEVY_EXCL_RSN_CD
     , A.CODE_VAL AS LEVY_EXCL_RSN_NM
     , B.ANS_WORDS_ID
     , B.MAIL_TTL_NM
     , B.MAIL_CN
  FROM TB_CMN_CODE A
  LEFT OUTER JOIN TB_CVLCPT_ANS_WORDS B 
       ON (A.CODE = B.ANS_RSN_CD
       AND B.USE_YN = 'Y' 
       AND B.ANS_SE_CD = '2'
       AND B.SGG_CD = #{sggCd}
       AND B.TASK_SE_CD = #{taskSeCd}
       )
 WHERE A.GRP_ID = 'FIM022'
   AND A.CODE LIKE '2%'
 ORDER BY A.CODE
</select>

<insert id="insertWarningWordsInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt">
/* 계도문 문구 설정 등록(warningWordsMapper.insertWarningWordsInfo) */
<selectKey resultType="string" keyProperty="ansWordsId" keyColumn="NEW_ID" order="BEFORE">
SELECT
       LPAD(CAST(IFNULL(MAX(ANS_WORDS_ID) + 1, 1) AS INT), 10, '0')
       AS NEW_ID 
FROM TB_CVLCPT_ANS_WORDS
</selectKey>
INSERT
  INTO TB_CVLCPT_ANS_WORDS(
       ANS_WORDS_ID
     , SGG_CD
     , TASK_SE_CD
     , ANS_SE_CD
     , DSTRBNC_YN
     , ANS_RSN_CD
     , ANS_RSN_NM
     , PRCS_SUMRY
     , MAIL_TTL_NM
     , MAIL_CN
     , USE_YN
     , REG_DT
     , RGTR
     , MDFCN_DT
     , MDFR
  )
VALUES (
       #{ansWordsId}
     , #{sggCd}
     , #{taskSeCd}
     , '2'
     , 'N'
     , #{ansRsnCd}
     , #{ansRsnNm}
     , '과태료 계고'
     , #{mailTtlNm}
     , #{mailCn}
     , 'Y'
     , <include refid="utility.now" />
     , #{modifiedBy}
     , <include refid="utility.now" />
     , #{modifiedBy}
  )
</insert>

<update id="updateWarningWordsInfo" parameterType="cokr.xit.fims.cvlc.CrdnCvlcpt">
/* 계도문 문구 설정 변경(warningWordsMapper.updateWarningWordsInfo) */
UPDATE TB_CVLCPT_ANS_WORDS
   SET MAIL_TTL_NM = #{mailTtlNm}
     , MAIL_CN     = #{mailCn}
     , MDFCN_DT    = <include refid="utility.now" />
     , MDFR        = #{modifiedBy}
 WHERE ANS_WORDS_ID = #{ansWordsId}
</update>

</mapper>