파일 저장 경로 설정 수정

dev
이범준 6 months ago
parent 04478268f9
commit b46cd216f2

@ -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);
}
}

@ -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 {}
public class FileController extends cokr.xit.base.file.web.FileController {
@Value("${app.file.root.path}")
private String fileRootPath;
public String getFileRootPath() {
return fileRootPath;
}
}

@ -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/

@ -20,7 +20,7 @@
</resultMap>
<sql id="fileDirs">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

@ -18,4 +18,11 @@
<typeHandler handler="cokr.xit.foundation.data.RowValueHandler" javaType="java.lang.Object"/>
</typeHandlers>
<plugins>
<plugin interceptor="cokr.xit.adds.AddsMapperSupport">
</plugin>
</plugins>
</configuration>
Loading…
Cancel
Save