물건번호 삭제 API 수정
This commit is contained in:
parent
11a3cd4acc
commit
b00df32722
@ -219,6 +219,8 @@ public class FileService {
|
|||||||
HttpServletRequest request, HttpServletResponse response, FileRequest fileRequest)
|
HttpServletRequest request, HttpServletResponse response, FileRequest fileRequest)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
|
System.out.println("fileRequest>>>" + fileRequest.toString());
|
||||||
|
|
||||||
// 필수값 체크
|
// 필수값 체크
|
||||||
if (fileRequest.getObjectNo() == null || fileRequest.getObjectNo().isEmpty()) {
|
if (fileRequest.getObjectNo() == null || fileRequest.getObjectNo().isEmpty()) {
|
||||||
throw new QcastException(
|
throw new QcastException(
|
||||||
@ -236,42 +238,46 @@ public class FileService {
|
|||||||
ErrorCode.NOT_FOUND, message.getMessage(" common.message.file.download.exists"));
|
ErrorCode.NOT_FOUND, message.getMessage(" common.message.file.download.exists"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 첨부파일 물리적 경로
|
try {
|
||||||
String strSeparator = File.separator;
|
// 첨부파일 물리적 경로
|
||||||
String filePath = baseDirPath + strSeparator + fileResponse.getObjectNo();
|
String strSeparator = File.separator;
|
||||||
if (fileResponse.getPlanNo() != null && !fileResponse.getPlanNo().isEmpty()) {
|
String filePath = baseDirPath + strSeparator + fileResponse.getObjectNo();
|
||||||
filePath += strSeparator + fileResponse.getPlanNo();
|
if (fileResponse.getPlanNo() != null && !fileResponse.getPlanNo().isEmpty()) {
|
||||||
}
|
filePath += strSeparator + fileResponse.getPlanNo();
|
||||||
filePath += strSeparator + fileResponse.getFaileName();
|
}
|
||||||
|
filePath += strSeparator + fileResponse.getFaileName();
|
||||||
|
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
log.error("### File not found: {}", filePath);
|
log.error("### File not found: {}", filePath);
|
||||||
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR);
|
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
String mimeType = URLConnection.guessContentTypeFromName(file.getName());
|
String mimeType = URLConnection.guessContentTypeFromName(file.getName());
|
||||||
if (mimeType == null) {
|
if (mimeType == null) {
|
||||||
mimeType = "application/octet-stream";
|
mimeType = "application/octet-stream";
|
||||||
}
|
}
|
||||||
|
|
||||||
String originalFileName = fileResponse.getFaileName();
|
String originalFileName = fileResponse.getFaileName();
|
||||||
String encodedFileName =
|
String encodedFileName =
|
||||||
URLEncoder.encode(originalFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
URLEncoder.encode(originalFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||||
|
|
||||||
response.setHeader("Content-Transfer-Encoding", "binary;");
|
response.setHeader("Content-Transfer-Encoding", "binary;");
|
||||||
response.setHeader("Pragma", "no-cache;");
|
response.setHeader("Pragma", "no-cache;");
|
||||||
response.setHeader("Expires", "-1;");
|
response.setHeader("Expires", "-1;");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"");
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"");
|
||||||
response.setContentType(mimeType);
|
response.setContentType(mimeType);
|
||||||
response.setContentLength((int) file.length());
|
response.setContentLength((int) file.length());
|
||||||
|
|
||||||
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
|
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
|
||||||
FileCopyUtils.copy(inputStream, response.getOutputStream());
|
FileCopyUtils.copy(inputStream, response.getOutputStream());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new QcastException(
|
throw new QcastException(
|
||||||
ErrorCode.INTERNAL_SERVER_ERROR,
|
ErrorCode.INTERNAL_SERVER_ERROR,
|
||||||
message.getMessage("common.message.file.download.error"));
|
message.getMessage("common.message.file.download.error"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,6 @@ public class FileRequest {
|
|||||||
@Schema(description = "zip 파일 이름")
|
@Schema(description = "zip 파일 이름")
|
||||||
private String zipFileName;
|
private String zipFileName;
|
||||||
|
|
||||||
@Schema(description = "planNo null 체크 Flag (NULL=1, NOT NULL=0)", defaultValue = "1")
|
@Schema(description = "planNo null 체크 Flag (NULL=1, NOT NULL=0)")
|
||||||
private String planNoNullChkFlg = "1";
|
private String planNoNullChkFlg;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -644,7 +644,7 @@
|
|||||||
/* sqlid : com.interplug.qcast.biz.object.deleteObject */
|
/* sqlid : com.interplug.qcast.biz.object.deleteObject */
|
||||||
UPDATE T_OBJECT
|
UPDATE T_OBJECT
|
||||||
SET
|
SET
|
||||||
DEL_FLG = '1'
|
ORG_DEL_FLG = '1'
|
||||||
, TEMP_DEL_FLG = '1'
|
, TEMP_DEL_FLG = '1'
|
||||||
, LAST_EDIT_DATETIME = GETDATE()
|
, LAST_EDIT_DATETIME = GETDATE()
|
||||||
, LAST_EDIT_USER = #{userId}
|
, LAST_EDIT_USER = #{userId}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user