From 620343aa048de44f50463b76eff002b246c53976 Mon Sep 17 00:00:00 2001 From: leebj Date: Fri, 28 Jun 2024 08:54:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=86=8C=EC=8A=A4=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/sql/mapper/base/file-mapper.xml | 98 ++++++++++++++----- 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/src/main/resources/sql/mapper/base/file-mapper.xml b/src/main/resources/sql/mapper/base/file-mapper.xml index 70ecdd0e..f682f283 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('files/', DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR FROM ( SELECT '010' INF_TYPE, 'interface/attachment/smg' DIR UNION @@ -29,16 +30,45 @@ SELECT '100' INF_TYPE, 'attachment/violation' DIR UNION SELECT '110' INF_TYPE, 'attachment/opinion' DIR UNION SELECT '190' INF_TYPE, 'attachment/capture' DIR - ) FILE_DIRS + ) FILE_DIRS + -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 WHERE FILE_ID IN (#{fileID}) - ORDER BY FILE_ID - -SELECT A.*, FILE_PATH 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 + , FILE_PATH URL FROM TB_FILE A AND A.INF_TYPE = #{infoType} @@ -46,16 +76,24 @@ SELECT A.*, FILE_PATH URL AND USE_YN = 'Y' - + + + - + - + - + /* 파일 등록(fileMapper.insertFile) */ @@ -101,31 +139,39 @@ 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 +DELETE + FROM TB_FILE WHERE FILE_ID IN (#{fileID})