<?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.cmmn.dao.ExtrStngMapper">

<select id="selectExtrBscStng" parameterType="cokr.xit.fims.cmmn.ExtrStngQuery" resultType="dataobject">
/* 추출 기본 설정 조회(extrStngMapper.selectExtrBscStng) */
SELECT EXTR_BSC_ID
     , SGG_CD
     , TASK_SE_CD
     , MOBILE_PAGE_TMPLT
  FROM TB_EXTR_BSC_STNG
 WHERE USE_YN = 'Y'
   AND SGG_CD = #{sggCd}
   AND TASK_SE_CD = #{taskSeCd}
   AND TMPLAT_ID = #{tmplatId}
</select>

<insert id="insertBscStng" parameterType="cokr.xit.fims.cmmn.ExtrForm">
/* PDF 자료 추출 템플릿 문구 설정 등록(extrStngMapper.insertBscStng) */
<selectKey resultType="string" keyProperty="extrBscId" keyColumn="NEW_ID" order="BEFORE">
	<include refid="numbering.key">
		<property name="TABLE_NAME" value="TB_EXTR_BSC_STNG" />
		<property name="TABLE_KEY" value="EXTR_BSC_ID" />
		<property name="pad" value="10" />
	</include>
</selectKey>
INSERT
  INTO TB_EXTR_BSC_STNG (
       EXTR_BSC_ID
     , SGG_CD
     , TASK_SE_CD
     , MOBILE_PAGE_TMPLT
     , USE_YN
  ) VALUES (
       #{extrBscId}
     , #{sggCd}
     , #{taskSeCd}
     , #{mobilePageTmplt}
     , 'Y'
  )
</insert>

<update id="updateBscStng" parameterType="cokr.xit.fims.cmmn.ExtrForm">
/* PDF 자료 추출 템플릿 문구 수정(extrStngMapper.updateBscStng) */
UPDATE TB_EXTR_BSC_STNG
   SET MOBILE_PAGE_TMPLT = #{mobilePageTmplt}
 WHERE EXTR_BSC_ID = #{extrBscId}
   AND USE_YN = 'Y'
</update>

<select id="selectExtrArtclStngList" parameterType="cokr.xit.fims.cmmn.ExtrStngQuery" resultType="dataobject">
/* 추출 항목 설정 조회(extrStngMapper.selectExtrArtclStngList) */
SELECT EXTR_FORM_ID
     , SGG_CD
     , TASK_SE_CD
     , TMPLAT_ID
     , EXTR_ARTCL_NM
     , EXTR_ARTCL_DSCRP
     , LEFT_PSTN
     , TOP_PSTN
     , WIDTH_SZ
     , HEIGHT_SZ
  FROM TB_EXTR_FORM_STNG
 WHERE USE_YN = 'Y'
   AND SGG_CD = #{sggCd}
   AND TASK_SE_CD = #{taskSeCd}
   AND TMPLAT_ID = #{tmplatId}
</select>

<insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.ExtrArtclStng">
/* 추출 설정 등록(extrStngMapper.insertArtclStng) */
<selectKey resultType="string" keyProperty="extrFormId" keyColumn="NEW_ID" order="BEFORE">
	<include refid="numbering.key">
		<property name="TABLE_NAME" value="TB_EXTR_FORM_STNG" />
		<property name="TABLE_KEY" value="EXTR_FORM_ID" />
		<property name="pad" value="10" />
	</include>
</selectKey>
INSERT
  INTO TB_EXTR_FORM_STNG (
       EXTR_FORM_ID
     , SGG_CD
     , TASK_SE_CD
     , TMPLAT_ID
     , EXTR_ARTCL_NM
     , EXTR_ARTCL_DSCRP
     , LEFT_PSTN
     , TOP_PSTN
     , WIDTH_SZ
     , HEIGHT_SZ
     , USE_YN
  ) VALUES (
       #{extrFormId}
     , #{sggCd}
     , #{taskSeCd}
     , #{tmplatId}
     , #{extrArtclNm}
     , #{extrArtclDscrp}
     , #{leftPstn}
     , #{topPstn}
     , #{widthSz}
     , #{heightSz}
     , 'Y'
  )
</insert>

<update id="updateArtclStng" parameterType="cokr.xit.fims.cmmn.ExtrArtclStng">
/* 추출 설정 수정(extrStngMapper.updateArtclStng) */
UPDATE TB_EXTR_FORM_STNG
   SET EXTR_ARTCL_NM   = #{extrArtclNm}
     , EXTR_ARTCL_DSCRP= #{extrArtclDscrp}
     , LEFT_PSTN       = #{leftPstn}
     , TOP_PSTN        = #{topPstn}
     , WIDTH_SZ        = #{widthSz}
     , HEIGHT_SZ       = #{heightSz}
 WHERE EXTR_FORM_ID = #{extrFormId}
   AND USE_YN = 'Y'
</update>

<update id="deleteArtclStng" parameterType="cokr.xit.fims.cmmn.ExtrForm">
/* 추출 설정 삭제(extrStngMapper.deleteArtclStng) */
UPDATE TB_EXTR_FORM_STNG
   SET USE_YN   = 'N'
 WHERE SGG_CD      = #{sggCd}
   AND TASK_SE_CD  = #{taskSeCd}
   AND TMPLAT_ID   = #{tmplatId}
   AND USE_YN = 'Y'
<if test='extrFormIDs != null'>
   AND EXTR_FORM_ID NOT IN (<foreach collection="extrFormIDs" item="EXTR_FORM_ID" separator=",">#{EXTR_FORM_ID}</foreach>)
</if>
</update>

</mapper>