1. 소스정리

2. 파일테이블 조회 쿼리 애스터리스크 제거
3. url 내 드라이브문자 제거
dev
이범준 5 months ago
parent 49ccd4817e
commit f9a7b1752f

@ -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(#{addsFileRootPath}, DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR , CONCAT(#{addsFileRootPath}, DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR
FROM ( FROM (
SELECT '00' INF_TYPE, 'attachment' DIR FROM DUAL UNION SELECT '00' INF_TYPE, 'attachment' DIR FROM DUAL UNION
@ -33,14 +34,48 @@
<sql id="selectFiles"> <sql id="selectFiles">
<if test="fileIDs != null"> <if test="fileIDs != null">
SELECT A.* SELECT A.FILE_ID
, REPLACE(FILE_PATH,#{type},'/files/') AS URL , 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
, (CASE
WHEN REPLACE(FILE_PATH,#{type},'/files/') LIKE '_:%'
THEN SUBSTR(REPLACE(FILE_PATH,#{type},'/files/'),3)
ELSE REPLACE(FILE_PATH,#{type},'/files/')
END) AS 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.* <if test="fileIDs == null">
, REPLACE(FILE_PATH,#{type},'/files/') AS URL <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
, (CASE
WHEN REPLACE(FILE_PATH,#{type},'/files/') LIKE '_:%'
THEN SUBSTR(REPLACE(FILE_PATH,#{type},'/files/'),3)
ELSE REPLACE(FILE_PATH,#{type},'/files/')
END) AS 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>
@ -51,16 +86,23 @@ AND ${by} = #{term}
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">/* 파일 등록(fileMapper.insertFile) */ <insert id="insertFile" parameterType="map">/* 파일 등록(fileMapper.insertFile) */
<selectKey keyProperty="file.id,file.path" keyColumn="NEW_ID,PATH" resultType="map" order="BEFORE"> <selectKey keyProperty="file.id,file.path" keyColumn="NEW_ID,PATH" resultType="map" order="BEFORE">
@ -104,31 +146,40 @@ 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">
DELETE FROM TB_FILE /* 파일 삭제(fileMapper.deleteFiles) */
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