From b46cd216f227e3f853d11d863b958cdd1198bf3c Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 30 May 2024 11:30:48 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=84=A4=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/adds/AddsMapperSupport.java | 30 +++++++++++++++++++ .../java/cokr/xit/base/FileController.java | 12 +++++++- src/main/resources/application.yml | 8 +++++ .../resources/sql/mapper/base/file-mapper.xml | 2 +- src/main/resources/sql/mybatis-config.xml | 9 +++++- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/main/java/cokr/xit/adds/AddsMapperSupport.java diff --git a/src/main/java/cokr/xit/adds/AddsMapperSupport.java b/src/main/java/cokr/xit/adds/AddsMapperSupport.java new file mode 100644 index 0000000..3c665de --- /dev/null +++ b/src/main/java/cokr/xit/adds/AddsMapperSupport.java @@ -0,0 +1,30 @@ +package cokr.xit.adds; + +import java.sql.SQLException; +import java.util.Map; + +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Signature; + +import cokr.xit.applib.ApplicationContextProvider; +import cokr.xit.base.FileController; +import cokr.xit.foundation.data.paging.MapperSupport; + +@Intercepts({ + @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}) +}) +public class AddsMapperSupport extends MapperSupport { + + @Override + protected Object update(Executor executor, MappedStatement mappedStatement, Object obj) throws SQLException { + String id = mappedStatement.getId(); + if(id.equals("cokr.xit.base.file.dao.FileMapper.insertFile")) { + FileController addsFileController = (FileController) ApplicationContextProvider.getApplicationContext().getBean("fileController"); + ((Map)obj).put("addsFileRootPath", addsFileController.getFileRootPath()); + } + return super.update(executor, mappedStatement, obj); + } + +} diff --git a/src/main/java/cokr/xit/base/FileController.java b/src/main/java/cokr/xit/base/FileController.java index 2d6605a..3b08d3f 100644 --- a/src/main/java/cokr/xit/base/FileController.java +++ b/src/main/java/cokr/xit/base/FileController.java @@ -1,6 +1,16 @@ package cokr.xit.base; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @Controller -public class FileController extends cokr.xit.base.file.web.FileController {} \ No newline at end of file +public class FileController extends cokr.xit.base.file.web.FileController { + + @Value("${app.file.root.path}") + private String fileRootPath; + + public String getFileRootPath() { + return fileRootPath; + } + +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7b267ad..491a87a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -45,6 +45,10 @@ propertyService: # - encoding: UTF-8 # filename: classpath*:properties/your-file-02.properties +app: + file: + root.path: /data/adds/files/ + --- spring: config: @@ -66,6 +70,8 @@ propertyService: app: api: host: http://localhost:9076 + file: + root.path: d:/data/adds/files/ --- spring: @@ -91,3 +97,5 @@ propertyService: app: api: host: http://localhost:9076 + file: + root.path: /data/adds/files/ diff --git a/src/main/resources/sql/mapper/base/file-mapper.xml b/src/main/resources/sql/mapper/base/file-mapper.xml index dfaac79..dbaafde 100644 --- a/src/main/resources/sql/mapper/base/file-mapper.xml +++ b/src/main/resources/sql/mapper/base/file-mapper.xml @@ -20,7 +20,7 @@ SELECT INF_TYPE - , CONCAT('d:/data/adds/files/', DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR + , CONCAT(#{addsFileRootPath}, DIR, DATE_FORMAT(CURRENT_DATE, '/%Y/%m/%d/')) DIR FROM ( SELECT '00' INF_TYPE, 'attachment' DIR FROM DUAL UNION SELECT '01' INF_TYPE, 'document' DIR FROM DUAL UNION diff --git a/src/main/resources/sql/mybatis-config.xml b/src/main/resources/sql/mybatis-config.xml index faa9415..1acfeda 100644 --- a/src/main/resources/sql/mybatis-config.xml +++ b/src/main/resources/sql/mybatis-config.xml @@ -17,5 +17,12 @@ - + + + + + + + + \ No newline at end of file