From f9a7b1752f1b60aad143aad57cbd5488fac9efe0 Mon Sep 17 00:00:00 2001 From: leebj Date: Fri, 28 Jun 2024 08:54:08 +0900 Subject: [PATCH] =?UTF-8?q?1.=20=EC=86=8C=EC=8A=A4=EC=A0=95=EB=A6=AC=202.?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=BF=BC=EB=A6=AC=20=EC=95=A0=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=81=AC=20=EC=A0=9C=EA=B1=B0=203.=20url=20?= =?UTF-8?q?=EB=82=B4=20=EB=93=9C=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/sql/mapper/base/file-mapper.xml | 107 +++++++++++++----- 1 file changed, 79 insertions(+), 28 deletions(-) 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})