diff --git a/src/main/resources/sql/mapper/base/file-mapper.xml b/src/main/resources/sql/mapper/base/file-mapper.xml index 8e7e4b2..66efa49 100644 --- a/src/main/resources/sql/mapper/base/file-mapper.xml +++ b/src/main/resources/sql/mapper/base/file-mapper.xml @@ -19,7 +19,8 @@ -SELECT INF_TYPE + +SELECT INF_TYPE , CONCAT(#{addsFileRootPath}, DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR FROM ( SELECT '00' INF_TYPE, 'attachment' DIR FROM DUAL UNION @@ -33,14 +34,48 @@ -SELECT A.* - , REPLACE(FILE_PATH,#{type},'/files/') AS 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 + , (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 WHERE FILE_ID IN (#{fileID}) - ORDER BY FILE_ID - -SELECT A.* - , REPLACE(FILE_PATH,#{type},'/files/') AS URL + ORDER BY FILE_ID + + + +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 AND A.INF_TYPE = #{infoType} @@ -51,16 +86,23 @@ AND ${by} = #{term} AND USE_YN = 'Y' - + + - + - + - + /* 파일 등록(fileMapper.insertFile) */ @@ -104,31 +146,40 @@ INSERT INTO TB_FILE ( ) -/* 파일 순서 변경(fileMapper.reorder) */ -UPDATE TB_FILE SET - SRT_ORD = CASE FILE_ID - WHEN #{fileID} THEN #{index} - + +/* 파일 순서 변경(fileMapper.reorder) */ +UPDATE TB_FILE + SET SRT_ORD = CASE FILE_ID + + WHEN #{fileID} THEN #{index} + ELSE SRT_ORD END -WHERE FILE_ID IN (#{fileID}) + WHERE FILE_ID IN (#{fileID}) + -/* 다운로드 횟수 증가(fileMapper.updateDownloadCount) */ + +/* 다운로드 횟수 증가(fileMapper.updateDownloadCount) */ UPDATE TB_FILE SET DNLD_CNT = DNLD_CNT + 1 WHERE USE_YN = 'Y' - AND FILE_ID IN (#{fileID}) + AND FILE_ID IN (#{fileID}) + -/* 파일 제거(fileMapper.removeFiles) */ -UPDATE TB_FILE SET - USE_YN = 'N' + +/* 파일 제거(fileMapper.removeFiles) */ +UPDATE TB_FILE + SET USE_YN = 'N' WHERE USE_YN = 'Y' AND FILE_ID IN (#{fileID}) AND INF_TYPE = #{infoType} - AND INF_KEY IN (#{infoKey}) + AND INF_KEY IN (#{infoKey}) + -/* 파일 삭제(fileMapper.deleteFiles) */ -DELETE FROM TB_FILE + +/* 파일 삭제(fileMapper.deleteFiles) */ +DELETE + FROM TB_FILE WHERE FILE_ID IN (#{fileID})