fix: 파일업로드 경로 properties로 extract

dev
Jonguk. Lim 6 months ago
parent ffa642aae5
commit f4288e5838

@ -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.adds.core.util.CoreSpringUtils;
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 = CoreSpringUtils.getFileController();
((Map)obj).put("addsFileRootPath", addsFileController.getFileRootPath());
}
return super.update(executor, mappedStatement, obj);
}
}

@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import cokr.xit.adds.core.auth.jwt.JwtTokenProvider;
import cokr.xit.adds.core.auth.jwt.JwtVerification;
import cokr.xit.adds.core.spring.config.ApplicationContextProvider;
import cokr.xit.base.FileController;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@ -54,6 +55,10 @@ public class CoreSpringUtils {
return (MessageUtil)getBean(MessageUtil.class);
}
public static FileController getFileController(){
return (FileController)getBean(FileController.class);
}
/**
*
* @return MessageSourceAccessor

@ -1,6 +1,15 @@
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.data.file.path}")
private String fileRootPath;
public String getFileRootPath() {
return fileRootPath;
}
}

@ -145,6 +145,8 @@ app:
data:
root:
path: d:/data/adds
file:
path: ${app.data.root.path}/files/
cors:
allowed-origins: http://localhost:9077
swagger:
@ -187,6 +189,8 @@ app:
data:
root:
path: /data/adds
file:
path: ${app.data.root.path}/files/
swagger:
url: 'http://211.119.124.9:${server.port}${server.servlet.context-path:}/'
desc: 사고마약류폐기지원시스템

@ -20,7 +20,7 @@
</resultMap>
<sql id="fileDirs">SELECT INF_TYPE
, CONCAT('/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,9 @@
<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