소스정리

main
이범준 5 months ago
parent 2f88d4547e
commit 620343aa04

@ -19,7 +19,8 @@
<result property="useYN" column="USE_YN"/> <result property="useYN" column="USE_YN"/>
</resultMap> </resultMap>
<sql id="fileDirs">SELECT INF_TYPE <sql id="fileDirs">
SELECT INF_TYPE
, CONCAT('files/', DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR , CONCAT('files/', DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR
FROM ( FROM (
SELECT '010' INF_TYPE, 'interface/attachment/smg' DIR UNION <!-- 국민 신문고 --> SELECT '010' INF_TYPE, 'interface/attachment/smg' DIR UNION <!-- 국민 신문고 -->
@ -29,16 +30,45 @@
SELECT '100' INF_TYPE, 'attachment/violation' DIR UNION <!-- 단속 정보 --> SELECT '100' INF_TYPE, 'attachment/violation' DIR UNION <!-- 단속 정보 -->
SELECT '110' INF_TYPE, 'attachment/opinion' DIR UNION <!-- 의견 진술 --> SELECT '110' INF_TYPE, 'attachment/opinion' DIR UNION <!-- 의견 진술 -->
SELECT '190' INF_TYPE, 'attachment/capture' DIR <!-- 캡쳐용 동영상 --> SELECT '190' INF_TYPE, 'attachment/capture' DIR <!-- 캡쳐용 동영상 -->
) FILE_DIRS</sql> ) FILE_DIRS
</sql>
<sql id="selectFiles"> <sql id="selectFiles">
<if test="fileIDs != null"> <if test="fileIDs != null">
SELECT A.*, FILE_PATH URL SELECT A.FILE_ID
, A.INF_TYPE
, A.INF_KEY
, A.SUB_TYPE
, A.FILE_NM
, A.FILE_PATH
, A.MIME_TYPE
, A.FILE_SIZE
, A.DNLD_CNT
, A.SRT_ORD
, A.USE_YN
, A.REG_DT
, A.RGTR
, A.FILE_PATH URL
FROM TB_FILE A FROM TB_FILE A
WHERE FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>) WHERE FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)
ORDER BY FILE_ID</if> ORDER BY FILE_ID
<if test="fileIDs == null"><include refid="utility.paging-prefix" /> </if>
SELECT A.*, FILE_PATH URL <if test="fileIDs == null">
<include refid="utility.paging-prefix" />
SELECT A.FILE_ID
, A.INF_TYPE
, A.INF_KEY
, A.SUB_TYPE
, A.FILE_NM
, A.FILE_PATH
, A.MIME_TYPE
, A.FILE_SIZE
, A.DNLD_CNT
, A.SRT_ORD
, A.USE_YN
, A.REG_DT
, A.RGTR
, FILE_PATH URL
FROM TB_FILE A FROM TB_FILE A
<where> <where>
<if test="infoType != null"> AND A.INF_TYPE = #{infoType}</if> <if test="infoType != null"> AND A.INF_TYPE = #{infoType}</if>
@ -46,16 +76,24 @@ SELECT A.*, FILE_PATH URL
AND USE_YN = 'Y' AND USE_YN = 'Y'
</where> </where>
<include refid="utility.orderBy" /> <include refid="utility.orderBy" />
<include refid="utility.paging-suffix" /></if></sql> <include refid="utility.paging-suffix" />
</if>
</sql>
<select id="getFileList" parameterType="map" resultType="dataobject">/* 파일 목록 조회(fileMapper.getFileList) */ <select id="getFileList" parameterType="map" resultType="dataobject">
<include refid="selectFiles" /></select> /* 파일 목록 조회(fileMapper.getFileList) */
<include refid="selectFiles" />
</select>
<select id="getFilesOf" parameterType="map" resultMap="fileRow">/* 파일 가져오기(fileMapper.getFilesOf) */ <select id="getFilesOf" parameterType="map" resultMap="fileRow">
<include refid="selectFiles" /></select> /* 파일 가져오기(fileMapper.getFilesOf) */
<include refid="selectFiles" />
</select>
<select id="getFiles" parameterType="map" resultMap="fileRow">/* 파일 가져오기(fileMapper.getFiles) */ <select id="getFiles" parameterType="map" resultMap="fileRow">
<include refid="selectFiles" /></select> /* 파일 가져오기(fileMapper.getFiles) */
<include refid="selectFiles" />
</select>
<insert id="insertFile" parameterType="map"> <insert id="insertFile" parameterType="map">
/* 파일 등록(fileMapper.insertFile) */ /* 파일 등록(fileMapper.insertFile) */
@ -101,31 +139,39 @@ INSERT INTO TB_FILE (
) )
</insert> </insert>
<update id="reorder" parameterType="map">/* 파일 순서 변경(fileMapper.reorder) */ <update id="reorder" parameterType="map">
UPDATE TB_FILE SET /* 파일 순서 변경(fileMapper.reorder) */
SRT_ORD = CASE FILE_ID UPDATE TB_FILE
<foreach collection="fileIDs" item="fileID" index="index" separator=" ">WHEN #{fileID} THEN #{index} SET SRT_ORD = CASE FILE_ID
<foreach collection="fileIDs" item="fileID" index="index" separator=" ">
WHEN #{fileID} THEN #{index}
</foreach> </foreach>
ELSE SRT_ORD END ELSE SRT_ORD END
WHERE FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)</update> WHERE FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)
</update>
<update id="updateDownloadCount" parameterType="map">/* 다운로드 횟수 증가(fileMapper.updateDownloadCount) */ <update id="updateDownloadCount" parameterType="map">
/* 다운로드 횟수 증가(fileMapper.updateDownloadCount) */
UPDATE TB_FILE SET UPDATE TB_FILE SET
DNLD_CNT = DNLD_CNT + 1 DNLD_CNT = DNLD_CNT + 1
WHERE USE_YN = 'Y' WHERE USE_YN = 'Y'
AND FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)</update> AND FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)
</update>
<update id="removeFiles" parameterType="map">/* 파일 제거(fileMapper.removeFiles) */ <update id="removeFiles" parameterType="map">
UPDATE TB_FILE SET /* 파일 제거(fileMapper.removeFiles) */
USE_YN = 'N' UPDATE TB_FILE
SET USE_YN = 'N'
WHERE USE_YN = 'Y' WHERE USE_YN = 'Y'
<if test="fileIDs != null"> AND FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)</if> <if test="fileIDs != null"> AND FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)</if>
<if test="infoKeys != null"> <if test="infoKeys != null">
AND INF_TYPE = #{infoType} AND INF_TYPE = #{infoType}
AND INF_KEY IN (<foreach collection="infoKeys" item="infoKey" separator=",">#{infoKey}</foreach>)</if></update> AND INF_KEY IN (<foreach collection="infoKeys" item="infoKey" separator=",">#{infoKey}</foreach>)</if>
</update>
<delete id="deleteFiles" parameterType="map">/* 파일 삭제(fileMapper.deleteFiles) */ <delete id="deleteFiles" parameterType="map">/* 파일 삭제(fileMapper.deleteFiles) */
DELETE FROM TB_FILE DELETE
FROM TB_FILE
<if test="fileIDs != null">WHERE FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)</if> <if test="fileIDs != null">WHERE FILE_ID IN (<foreach collection="fileIDs" item="fileID" separator=",">#{fileID}</foreach>)</if>
</delete> </delete>

Loading…
Cancel
Save