<?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.OtptStngMapper">

<select id="selectOtptBscStng" parameterType="cokr.xit.fims.cmmn.OtptStngQuery" resultType="dataobject">
/* 출력물 기본 설정 조회(otptStngMapper.selectOtptBscStng) */
SELECT OTPT_BSC_ID
     , SGG_CD
     , TASK_SE_CD
     , SNDNG_SE_CD
     , PAPER_SE_CD
     , FOLD_LINE_PSTN_SE_CD
     , BCRN_IMG_PATH
     , BCRN_IMG_FILE_NM
     , OTPT_PHOTO_CNT
  FROM TB_OTPT_BSC_STNG
 WHERE USE_YN = 'Y'
   AND SGG_CD = #{sggCd}
   AND TASK_SE_CD = #{taskSeCd}
   AND SNDNG_SE_CD = #{sndngSeCd}
   AND PAPER_SE_CD = #{paperSeCd}
</select>

<insert id="insertBscStng" parameterType="cokr.xit.fims.cmmn.OtptForm">
/* 출력 기본 설정 등록(otptStngMapper.insertBscStng) */
<selectKey resultType="string" keyProperty="otptBscId" keyColumn="NEW_ID" order="BEFORE">
	<include refid="numbering.key">
		<property name="TABLE_NAME" value="TB_OTPT_BSC_STNG" />
		<property name="TABLE_KEY" value="OTPT_BSC_ID" />
		<property name="pad" value="10" />
	</include>
</selectKey>
INSERT
  INTO TB_OTPT_BSC_STNG (
       OTPT_BSC_ID
     , SGG_CD
     , TASK_SE_CD
     , SNDNG_SE_CD
     , PAPER_SE_CD
     , FOLD_LINE_PSTN_SE_CD
     <if test="bcrnImgPath != null and bcrnImgPath != ''">
     , BCRN_IMG_PATH
     , BCRN_IMG_FILE_NM
     </if>
     , OTPT_PHOTO_CNT
     , USE_YN
     , REG_DT
     , RGTR
  ) VALUES (
       #{otptBscId}
     , #{sggCd}
     , #{taskSeCd}
     , #{sndngSeCd}
     , #{paperSeCd}
     , #{foldLinePstnSeCd}
     <if test="bcrnImgPath != null and bcrnImgPath != ''">
     , #{bcrnImgPath}
     , #{bcrnImgFileNm}
     </if>
     , #{otptPhotoCnt}
     , 'Y'
     , <include refid="utility.now" />
     , #{createdBy}
  )
</insert>

<update id="updateBscStng" parameterType="cokr.xit.fims.cmmn.OtptForm">
/* 출력 기본 설정 수정(otptStngMapper.updateBscStng) */
UPDATE TB_OTPT_BSC_STNG
   SET FOLD_LINE_PSTN_SE_CD = #{foldLinePstnSeCd}
     <if test="bcrnImgPath != null and bcrnImgPath != ''">
     , BCRN_IMG_PATH        = #{bcrnImgPath}
     , BCRN_IMG_FILE_NM     = #{bcrnImgFileNm}
     </if>
     , OTPT_PHOTO_CNT       = #{otptPhotoCnt}
     , MDFCN_DT        = <include refid="utility.now" />
     , MDFR            = #{modifiedBy}
 WHERE OTPT_BSC_ID = #{otptBscId}
   AND USE_YN = 'Y'
</update>

<select id="selectOtptArtclStngList" parameterType="cokr.xit.fims.cmmn.OtptStngQuery" resultType="dataobject">
/* 출력 항목 설정 조회(otptStngMapper.selectOtptArtclStngList) */
SELECT OTPT_FORM_ID
     , SGG_CD
     , TASK_SE_CD
     , SNDNG_SE_CD
     , PAPER_SE_CD
     , OTPT_ARTCL_NM
     , LEFT_PSTN
     , TOP_PSTN
     , WIDTH_SZ
     , HEIGHT_SZ
     , FONT_NM
     , FONT_SZ
     , FONT_COLR
     , FONT_STYLE
     , TEXT_SORT
     , LINE_CHG_YN
     , OTPT_ARTCL_SEQ
  FROM TB_OTPT_FORM_STNG
 WHERE USE_YN = 'Y'
   AND SGG_CD = #{sggCd}
   AND TASK_SE_CD = #{taskSeCd}
   AND SNDNG_SE_CD = #{sndngSeCd}
   AND PAPER_SE_CD = #{paperSeCd}
 ORDER BY OTPT_ARTCL_SEQ
</select>

<insert id="insertArtclStng" parameterType="cokr.xit.fims.cmmn.OtptArtclStng">
/* 출력 설정 등록(otptStngMapper.insertArtclStng) */
<selectKey resultType="string" keyProperty="otptFormId" keyColumn="NEW_ID" order="BEFORE">
	<include refid="numbering.key">
		<property name="TABLE_NAME" value="TB_OTPT_FORM_STNG" />
		<property name="TABLE_KEY" value="OTPT_FORM_ID" />
		<property name="pad" value="10" />
	</include>
</selectKey>
INSERT
  INTO TB_OTPT_FORM_STNG (
       OTPT_FORM_ID
     , SGG_CD
     , TASK_SE_CD
     , SNDNG_SE_CD
     , PAPER_SE_CD
     , OTPT_ARTCL_NM
     , LEFT_PSTN
     , TOP_PSTN
     , WIDTH_SZ
     , HEIGHT_SZ
     , TEXT_SORT
     , LINE_CHG_YN
     , FONT_NM
     , FONT_SZ
     , FONT_COLR
     , FONT_STYLE
     , OTPT_ARTCL_SEQ
     , USE_YN
     , REG_DT
     , RGTR
  ) VALUES (
       #{otptFormId}
     , #{sggCd}
     , #{taskSeCd}
     , #{sndngSeCd}
     , #{paperSeCd}
     , #{otptArtclNm}
     , #{leftPstn}
     , #{topPstn}
     , #{widthSz}
     , #{heightSz}
     , #{textSort}
     , #{lineChgYn}
     , #{fontNm}
     , #{fontSz}
     , #{fontColr}
     , #{fontStyle}
     , #{otptArtclSeq}
     , 'Y'
     , <include refid="utility.now" />
     , #{createdBy}
  )
</insert>

<update id="updateArtclStng" parameterType="cokr.xit.fims.cmmn.OtptArtclStng">
/* 출력 설정 수정(otptStngMapper.updateArtclStng) */
UPDATE TB_OTPT_FORM_STNG
   SET OTPT_ARTCL_NM   = #{otptArtclNm}
     , LEFT_PSTN       = #{leftPstn}
     , TOP_PSTN        = #{topPstn}
     , WIDTH_SZ        = #{widthSz}
     , HEIGHT_SZ       = #{heightSz}
     , TEXT_SORT       = #{textSort}
     , LINE_CHG_YN     = #{lineChgYn}
     , FONT_NM         = #{fontNm}
     , FONT_SZ         = #{fontSz}
     , FONT_COLR       = #{fontColr}
     , FONT_STYLE      = #{fontStyle}
     , OTPT_ARTCL_SEQ  = #{otptArtclSeq}
     , MDFCN_DT        = <include refid="utility.now" />
     , MDFR            = #{modifiedBy}
 WHERE OTPT_FORM_ID = #{otptFormId}
   AND USE_YN = 'Y'
</update>

<update id="deleteArtclStng" parameterType="cokr.xit.fims.cmmn.OtptForm">
/* 출력 설정 삭제(otptStngMapper.deleteArtclStng) */
UPDATE TB_OTPT_FORM_STNG
   SET USE_YN   = 'N'
     , MDFCN_DT = <include refid="utility.now" />
     , MDFR     = #{modifiedBy}
 WHERE SGG_CD      = #{sggCd}
   AND TASK_SE_CD  = #{taskSeCd}
   AND SNDNG_SE_CD = #{sndngSeCd}
   AND PAPER_SE_CD = #{paperSeCd}
   AND USE_YN = 'Y'
<if test='otptFormIDs != null'>
   AND OTPT_FORM_ID NOT IN (<foreach collection="otptFormIDs" item="OTPT_FORM_ID" separator=",">#{OTPT_FORM_ID}</foreach>)
</if>
</update>

</mapper>
