<?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.sprt.dao.MediaMapper">

<select id="selectMosaicList" parameterType="string" resultType="dataobject">
/* 이미지파일 모자이크 정보 조회 (mediaMapper.selectMosaicList) */
SELECT MOSC_ID
     , FILE_ID
     , X_AXS
     , Y_AXS
     , MOSC_LEN
     , MOSC_HGT
  FROM TB_FILE_MOSC
 WHERE FILE_ID = #{fileId}
   AND DEL_YN = 'N'
</select>

<update id="reorder" parameterType="map">
/* 이미지파일 순서 변경 (mediaMapper.reorder) */
UPDATE TB_FILE
   SET SRT_ORD = #{srtOrd}
 WHERE FILE_ID = #{fileId}
</update>

<insert id="copyMosaicInfo" parameterType="map">
/* 모자이크 정보 복사(mediaMapper.copyMosaicInfo) */
<selectKey resultType="string" keyProperty="newMoscId" keyColumn="NEW_ID" order="BEFORE">
SELECT
       LPAD(CAST(IFNULL(MAX(MOSC_ID) + 1, 1) AS INT), 10, '0')
       AS NEW_ID
  FROM TB_FILE_MOSC
</selectKey>
INSERT
  INTO TB_FILE_MOSC (
       MOSC_ID
     , FILE_ID
     , X_AXS
     , Y_AXS
     , MOSC_LEN
     , MOSC_HGT
     , DEL_YN       <!-- 삭제 여부 -->
     , REG_DT       <!-- 등록 일시 -->
     , RGTR         <!-- 등록자 -->
     , MDFCN_DT     <!-- 수정 일시 -->
     , MDFR         <!-- 수정자 -->
)
SELECT #{newMoscId}
     , #{newFileId}
     , X_AXS
     , Y_AXS
     , MOSC_LEN
     , MOSC_HGT
     , 'N'                             <!-- 삭제 여부 -->
     , <include refid="utility.now" /> <!-- 등록 일시 -->
     , #{currentUser.id}               <!-- 등록자 -->
     , <include refid="utility.now" /> <!-- 수정 일시 -->
     , #{currentUser.id}               <!-- 수정자 -->
  FROM TB_FILE_MOSC
 WHERE FILE_ID = #{oldFileId}
   AND MOSC_ID = #{oldMoscId}
   AND DEL_YN = 'N'
</insert>

</mapper>