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