파일 업로드 vm옵션으로 변경 -Dpath.upload.storage=LOCAL 로 변경해주세요

This commit is contained in:
주수현
2025-06-26 15:55:09 +09:00
parent 6b54f605c8
commit 8241b3d77d
35 changed files with 355 additions and 160 deletions

View File

@@ -113,7 +113,7 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
-Dspring.datasource.username=ko_research -Dspring.datasource.username=ko_research
-Dspring.datasource.password=koresearch1@#4 -Dspring.datasource.password=koresearch1@#4
-Daes.secret-key=092HW829O0A0AVR0 -Daes.secret-key=092HW829O0A0AVR0
-Dpath.upload.storage=SFTP -Dpath.upload.storage=LOCAL
-Dpath.upload.sftp.public=/home/etribe/data/upload -Dpath.upload.sftp.public=/home/etribe/data/upload
-Dpath.upload.sftp.tmpdir=${user.home}/upload/tmpdir -Dpath.upload.sftp.tmpdir=${user.home}/upload/tmpdir
-Dfile.upload.sftp.ip=115.68.193.117 -Dfile.upload.sftp.ip=115.68.193.117
@@ -121,6 +121,9 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
-Dfile.upload.sftp.password=Etribe@3415 -Dfile.upload.sftp.password=Etribe@3415
-Dfile.upload.sftp.port=22 -Dfile.upload.sftp.port=22
``` ```
** 주의 : 운영서버일 경우 -Dpath.upload.storage=SFTP로 설정
## JDBC 및 데이터 핸들링 구성 옵션 ## JDBC 및 데이터 핸들링 구성 옵션

View File

@@ -40,7 +40,7 @@ class CreateNoticeDao implements CreateNoticePortOut {
mapper.createNotice(dto); mapper.createNotice(dto);
if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) { if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) {
mapper.createNoticeHasUploadFile(new CreateNoticeHasUploadFilesParam( mapper.createNoticeUploadFile(new CreateNoticeHasUploadFilesParam(
dto.getId(), dto.getId(),
dto.getFileMappingId().stream() dto.getFileMappingId().stream()
.map(Long::parseLong) .map(Long::parseLong)

View File

@@ -7,5 +7,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface CreateNoticeMapper { public interface CreateNoticeMapper {
void createNotice(CreateNoticeDto dto); void createNotice(CreateNoticeDto dto);
void createNoticeHasUploadFile(CreateNoticeHasUploadFilesParam param); void createNoticeUploadFile(CreateNoticeHasUploadFilesParam param);
} }

View File

@@ -4,8 +4,10 @@ import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePo
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice; import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd; import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile; import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -19,6 +21,8 @@ class GetNoticeDao implements GetNoticePortOut {
private final GetNoticeMapper mapper; private final GetNoticeMapper mapper;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
@Transactional @Transactional
@@ -35,13 +39,13 @@ class GetNoticeDao implements GetNoticePortOut {
// 참조 URL 전달 // 참조 URL 전달
uploadFile.setReferURL( uploadFile.setReferURL(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
uploadFile.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
uploadFile.getPath(), uploadFile.getPath(),
uploadFile.getName())); uploadFile.getName()));
// attachment URL 전달 // attachment URL 전달
uploadFile.setAttachmentURL( uploadFile.setAttachmentURL(
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
uploadFile.getType().getFileStorageType(), uploadFile.getId())); FileStorageType.valueOf(uploadStorageType), uploadFile.getId()));
return uploadFile; return uploadFile;
}) })

View File

@@ -20,7 +20,7 @@ class RemoveNoticesDao implements RemoveNoticesPortOut {
String loginUser = CommonUtil.getLoginUsername();; String loginUser = CommonUtil.getLoginUsername();;
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
mapper.deleteNoticeHasFiles( mapper.deleteNoticeUploadFiles(
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser)); new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));
mapper.deleteNotices( mapper.deleteNotices(
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser)); new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));

View File

@@ -6,5 +6,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface RemoveNoticesMapper { public interface RemoveNoticesMapper {
void deleteNotices(RemoveNoticesParam param); void deleteNotices(RemoveNoticesParam param);
void deleteNoticeHasFiles(RemoveNoticesParam param); void deleteNoticeUploadFiles(RemoveNoticesParam param);
} }

View File

@@ -1,24 +1,25 @@
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence; package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto; import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut; import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut;
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd; import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile; import app.module.core.config.application.annotation.UpdateCommand;
import app.module.core.config.application.util.CommonUtil; import app.module.core.config.application.util.CommonUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Slf4j
@Repository @Repository
@RequiredArgsConstructor @RequiredArgsConstructor
class UpdateNoticeDao implements UpdateNoticePortOut { class UpdateNoticeDao implements UpdateNoticePortOut {
private final UpdateNoticeMapper mapper; private final UpdateNoticeMapper mapper;
@Override @Override
@UpdateCommand
public void operate(UpdateNoticeCmd command) { public void operate(UpdateNoticeCmd command) {
mapper.updateNotice( mapper.updateNotice(
new UpdateNoticeDto( new UpdateNoticeDto(
@@ -33,21 +34,5 @@ class UpdateNoticeDao implements UpdateNoticePortOut {
CommonUtil.getLoginUsername() CommonUtil.getLoginUsername()
)); ));
// 첨부파일 초기화
mapper.deleteFileUploads(new NoticeHasUploadFile(command.getId()));
// 첨부파일 있을 시, 등록
if (command.getFileMappingId() != null && !command.getFileMappingId().isEmpty()) {
mapper.createFileUploads(new CreateUploadFileParam(
command.getId(),
command.getFileMappingId().stream()
.map(Long::parseLong)
.toList(),
LocalDateTime.now(),
CommonUtil.getLoginUsername(),
LocalDateTime.now(),
CommonUtil.getLoginUsername()
));
}
} }
} }

View File

@@ -1,14 +1,9 @@
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence; package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto; import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface UpdateNoticeMapper { public interface UpdateNoticeMapper {
void updateNotice(UpdateNoticeDto dto); void updateNotice(UpdateNoticeDto dto);
void deleteFileUploads(NoticeHasUploadFile noticeHasUploadFile);
void createFileUploads(CreateUploadFileParam param);
} }

View File

@@ -1,18 +0,0 @@
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@AllArgsConstructor
public class CreateUploadFileParam {
private Long id;
private List<Long> fileMappingId;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -3,6 +3,9 @@ package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model.UpdateNoticeReqVO; import app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model.UpdateNoticeReqVO;
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn; import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd; import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
import app.module.core.config.application.enums.FileUploadType;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortIn;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor @RequiredArgsConstructor
class UpdateNoticeController { class UpdateNoticeController {
private final UpdateNoticePortIn updateNoticePortIn; private final UpdateNoticePortIn updateNoticePortIn;
private final UpdateFilePortIn updateFilePortIn;
@PutMapping(path = "/api/communication/notices/update") @PutMapping(path = "/api/communication/notices/update")
ResponseEntity<?> operate(@RequestBody @Valid UpdateNoticeReqVO reqVO, BindingResult bindingResult) { ResponseEntity<?> operate(@RequestBody @Valid UpdateNoticeReqVO reqVO, BindingResult bindingResult) {
@@ -26,6 +30,13 @@ class UpdateNoticeController {
.body(bindingResult.getFieldErrors()); .body(bindingResult.getFieldErrors());
} }
updateFilePortIn.operate(
new UpdateFileCmd(
reqVO.getId(),
reqVO.getFileMappingId().stream().map(Long::parseLong).toList(),
FileUploadType.NOTICE)
);
updateNoticePortIn.operate( updateNoticePortIn.operate(
new UpdateNoticeCmd( new UpdateNoticeCmd(
reqVO.getId(), reqVO.getId(),
@@ -34,8 +45,8 @@ class UpdateNoticeController {
reqVO.getVisible(), reqVO.getVisible(),
reqVO.getStartDate(), reqVO.getStartDate(),
reqVO.getEndDate(), reqVO.getEndDate(),
reqVO.getFileMappingId() reqVO.getFileMappingId())
)); );
return ResponseEntity.status(HttpStatus.OK).body(reqVO); return ResponseEntity.status(HttpStatus.OK).body(reqVO);
} }

View File

@@ -1,11 +1,13 @@
package app.module.admin.usecase.editor.adapters.web; package app.module.admin.usecase.editor.adapters.web;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.config.application.enums.FileUploadType; import app.module.core.config.application.enums.FileUploadType;
import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn; import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn;
import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage; import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import java.io.IOException; import java.io.IOException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@@ -18,6 +20,8 @@ public class EditorImageUploadController {
private final SaveToStoragePortIn saveToStoragePortIn; private final SaveToStoragePortIn saveToStoragePortIn;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@PostMapping(path = "/api/editorImage/upload") @PostMapping(path = "/api/editorImage/upload")
ResponseEntity<?> editorImageUpload(MultipartFile editorImage) throws IOException { ResponseEntity<?> editorImageUpload(MultipartFile editorImage) throws IOException {
@@ -27,7 +31,7 @@ public class EditorImageUploadController {
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body( .body(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
saveToStorage.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
saveToStorage.getPath(), saveToStorage.getPath(),
saveToStorage.getName())); saveToStorage.getName()));
} }

View File

@@ -37,23 +37,16 @@
) )
</insert> </insert>
<insert id="createNoticeHasUploadFile"> <update id="createNoticeUploadFile">
<!-- createNoticeHasUploadFile 게시글 등록 시, 첨부파일 join 데이터 등록 --> update upload_file
INSERT INTO notice_has_upload_file set mapping_id = #{id},
( <include refid="common.fields.UpdateBaseSet"/>
notice_id, where id IN (
upload_files_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
<foreach collection="fileMappingIds" item="fileId" separator=","> <foreach collection="fileMappingIds" item="fileId" separator=",">
( #{fileId}
#{id},
#{fileId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</foreach> </foreach>
</insert> )
</update>
</mapper> </mapper>

View File

@@ -29,8 +29,7 @@
resultType="app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile"> resultType="app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile">
/* getUploadFiles 상세 게시글 조회 시, 첨부파일 조회 */ /* getUploadFiles 상세 게시글 조회 시, 첨부파일 조회 */
SELECT SELECT
awuf.notice_id AS noticeId, uf.mapping_id,
awuf.upload_files_id AS uploadfileId,
uf.id AS id, uf.id AS id,
uf.created_at AS createdAt, uf.created_at AS createdAt,
uf.created_by AS createdBy, uf.created_by AS createdBy,
@@ -41,9 +40,7 @@
uf.origin_name AS originName, uf.origin_name AS originName,
uf.path AS path, uf.path AS path,
uf.type AS type uf.type AS type
FROM notice_has_upload_file awuf FROM upload_file uf
INNER JOIN upload_file uf WHERE uf.mapping_id = #{id} AND uf.is_deleted = false AND uf.type ='NOTICE'
ON awuf.upload_files_id = uf.id
WHERE awuf.notice_id = #{id} AND awuf.is_deleted = false
</select> </select>
</mapper> </mapper>

View File

@@ -78,16 +78,15 @@
resultType="app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles"> resultType="app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles">
/* getUploadFiles : 게시물 리스트의 대표 이미지 */ /* getUploadFiles : 게시물 리스트의 대표 이미지 */
SELECT SELECT
awuf.notice_id, uf.mapping_id as notice_id,
uf.id, uf.id,
uf.type, uf.type,
uf.path, uf.path,
uf.name, uf.name,
uf.origin_name, uf.origin_name,
uf.file_length uf.file_length
FROM notice_has_upload_file awuf FROM upload_file uf
INNER JOIN upload_file uf ON awuf.upload_files_id = uf.id WHERE uf.mapping_id IN
WHERE awuf.notice_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")"> <foreach collection="ids" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>

View File

@@ -13,11 +13,11 @@
</foreach> </foreach>
</update> </update>
<update id="deleteNoticeHasFiles"> <update id="deleteNoticeUploadFiles">
/* deleteNoticeHasFiles : 게시물-파일 매핑 논리 삭제 */ /* deleteNoticeUploadFiles : 게시물-파일 매핑 논리 삭제 */
UPDATE notice_has_upload_file UPDATE upload_file
SET <include refid="common.fields.DeleteBaseSet" /> SET <include refid="common.fields.DeleteBaseSet" />
WHERE notice_id IN WHERE type='NOTICE' and mapping_id IN
<foreach collection="removeIds" item="id" open="(" separator="," close=")"> <foreach collection="removeIds" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>

View File

@@ -4,32 +4,6 @@
<mapper <mapper
namespace="app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.UpdateNoticeMapper"> namespace="app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.UpdateNoticeMapper">
<update id="deleteFileUploads">
/* deleteFileUploads 게시글 수정 시, 첨부파일 join 데이터 삭제 */
UPDATE notice_has_upload_file
SET
<include refid="common.fields.DeleteBaseSet"/>
WHERE notice_id = #{noticeId}
</update>
<insert id="createFileUploads">
/* createFileUploads 게시글 수정 시, 첨부파일 join 데이터 등록 */
INSERT INTO notice_has_upload_file
(
notice_id,
upload_files_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
<foreach collection="fileMappingId" item="fileId" separator=",">
(
#{id},
#{fileId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</foreach>
</insert>
<update id="updateNotice"> <update id="updateNotice">
/* updateNotice 게시글 수정 */ /* updateNotice 게시글 수정 */
UPDATE notice UPDATE notice

View File

@@ -10,4 +10,9 @@ public enum FileStorageType {
S3("AWS S3 스토리지"), S3("AWS S3 스토리지"),
SFTP("SFTP"); SFTP("SFTP");
private final String desc; private final String desc;
private String name;
public String getName() {
return name();
}
} }

View File

@@ -10,12 +10,12 @@ import lombok.RequiredArgsConstructor;
@JsonFormat(shape = JsonFormat.Shape.OBJECT) @JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum FileUploadType { public enum FileUploadType {
// URI og:image 용 이미지 파일 // URI og:image 용 이미지 파일
OG_IMAGE(FileStorageType.LOCAL, "/ogImage", Set.of(AcceptableFileType.IMAGE)), OG_IMAGE(Set.of(FileStorageType.LOCAL), "/ogImage", Set.of(AcceptableFileType.IMAGE)),
// WEB Editor 이미지 파일 // WEB Editor 이미지 파일
EDITOR_IMAGE(FileStorageType.LOCAL, "/editorImage", Set.of(AcceptableFileType.IMAGE)), EDITOR_IMAGE(Set.of(FileStorageType.LOCAL), "/editorImage", Set.of(AcceptableFileType.IMAGE)),
PUBLIC( PUBLIC(
FileStorageType.LOCAL, Set.of(FileStorageType.LOCAL),
"/common", "/common",
Set.of( Set.of(
AcceptableFileType.IMAGE, AcceptableFileType.IMAGE,
@@ -28,7 +28,7 @@ public enum FileUploadType {
AcceptableFileType.PDF, AcceptableFileType.PDF,
AcceptableFileType.ZIP)), AcceptableFileType.ZIP)),
PRIVATE( PRIVATE(
FileStorageType.LOCAL, Set.of(FileStorageType.LOCAL),
"/private", "/private",
Set.of( Set.of(
AcceptableFileType.IMAGE, AcceptableFileType.IMAGE,
@@ -41,7 +41,10 @@ public enum FileUploadType {
AcceptableFileType.PDF, AcceptableFileType.PDF,
AcceptableFileType.ZIP)), AcceptableFileType.ZIP)),
NOTICE( NOTICE(
FileStorageType.SFTP, Set.of(
FileStorageType.SFTP,
FileStorageType.LOCAL
),
"/notice", "/notice",
Set.of( Set.of(
AcceptableFileType.IMAGE, AcceptableFileType.IMAGE,
@@ -55,15 +58,15 @@ public enum FileUploadType {
AcceptableFileType.ZIP)), AcceptableFileType.ZIP)),
RECEIPT( RECEIPT(
FileStorageType.SFTP, Set.of(FileStorageType.SFTP,FileStorageType.LOCAL),
"/receipt", "/receipt",
Set.of( Set.of(
AcceptableFileType.IMAGE AcceptableFileType.IMAGE
) )
); );
private final FileStorageType fileStorageType; private final Set<FileStorageType> fileStorageType;
private final String subPath; private final String subPath;
private final Set<AcceptableFileType> acceptableFileTypes; private final Set<AcceptableFileType> acceptableFileTypes;

View File

@@ -1,7 +1,7 @@
package app.module.core.config.application.util; package app.module.core.config.application.util;
import app.module.core.config.adapters.persistence.entity.UploadFile;
import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector; import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException; import com.jcraft.jsch.SftpException;
@@ -28,7 +28,7 @@ public class SftpFileDeleteUtil {
* @throws JSchException SFTP 연결 오류 * @throws JSchException SFTP 연결 오류
* @throws SftpException SFTP 작업 오류 * @throws SftpException SFTP 작업 오류
*/ */
public void deleteRealFile(UploadFile deleteFile) throws JSchException, SftpException { public void deleteRealFile(UploadFileDto deleteFile) throws JSchException, SftpException {
if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) { if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) {
log.error("Invalid file information: {}", deleteFile); log.error("Invalid file information: {}", deleteFile);
throw new IllegalArgumentException("Invalid file information"); throw new IllegalArgumentException("Invalid file information");

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.article.getArticle.adapters.persistence; package app.module.core.usecase.article.getArticle.adapters.persistence;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut; import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut;
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle; import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd; import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
@@ -9,6 +10,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -19,6 +21,9 @@ class GetArticleDao implements GetArticlePortOut {
private final GetArticleMapper mapper; private final GetArticleMapper mapper;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
@Transactional @Transactional
public Optional<GetArticle> operate(GetArticleCmd command) { public Optional<GetArticle> operate(GetArticleCmd command) {
@@ -34,13 +39,13 @@ class GetArticleDao implements GetArticlePortOut {
// 참조 URL 전달 // 참조 URL 전달
uploadFile.setReferURL( uploadFile.setReferURL(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
uploadFile.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
uploadFile.getPath(), uploadFile.getPath(),
uploadFile.getName())); uploadFile.getName()));
// attachment URL 전달 // attachment URL 전달
uploadFile.setAttachmentURL( uploadFile.setAttachmentURL(
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
uploadFile.getType().getFileStorageType(), uploadFile.getId())); FileStorageType.valueOf(uploadStorageType), uploadFile.getId()));
return uploadFile; return uploadFile;
}) })

View File

@@ -1,12 +1,14 @@
package app.module.core.usecase.file.createFile.adapters.persistence; package app.module.core.usecase.file.createFile.adapters.persistence;
import app.module.core.config.adapters.persistence.entity.UploadFile; import app.module.core.config.adapters.persistence.entity.UploadFile;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut; import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile; import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd; import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import java.util.Optional; import java.util.Optional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
@@ -15,6 +17,10 @@ class CreateFileDao implements CreateFilePortOut {
private final CreateFileMapper mapper; private final CreateFileMapper mapper;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
public Optional<CreateFile> operate(CreateFileCmd command) { public Optional<CreateFile> operate(CreateFileCmd command) {
UploadFile uploadFile = new UploadFile( UploadFile uploadFile = new UploadFile(
@@ -23,7 +29,7 @@ class CreateFileDao implements CreateFilePortOut {
command.getPath(), command.getPath(),
command.getName(), command.getName(),
command.getOriginName(), command.getOriginName(),
command.getFileLength()); command.getFileLength() );
mapper.insertFile(uploadFile); mapper.insertFile(uploadFile);
@@ -37,11 +43,11 @@ class CreateFileDao implements CreateFilePortOut {
uploadFile.getFileLength(), uploadFile.getFileLength(),
// 참조 URL 전달 // 참조 URL 전달
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
uploadFile.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
uploadFile.getPath(), uploadFile.getPath(),
uploadFile.getName()), uploadFile.getName()),
// attachment URL 전달 // attachment URL 전달
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
uploadFile.getType().getFileStorageType(), uploadFile.getId()))); FileStorageType.valueOf(uploadStorageType), uploadFile.getId())));
} }
} }

View File

@@ -20,6 +20,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.tika.Tika; import org.apache.tika.Tika;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -30,6 +31,8 @@ public class SaveToStorageService implements SaveToStoragePortIn {
private final MessageUtil messageUtil; private final MessageUtil messageUtil;
private final Tika tika; private final Tika tika;
private final Set<FileUploadStrategy> fileUploadStrategies; private final Set<FileUploadStrategy> fileUploadStrategies;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
public Optional<SaveToStorage> operate(FileUploadType fileUploadType, public Optional<SaveToStorage> operate(FileUploadType fileUploadType,
@@ -45,7 +48,7 @@ public class SaveToStorageService implements SaveToStoragePortIn {
String subPath = getDirPath(fileUploadType.getSubPath()); String subPath = getDirPath(fileUploadType.getSubPath());
String createFilename = getUUIDFilename(getFileExtension(originalFilename).orElse(null)); String createFilename = getUUIDFilename(getFileExtension(originalFilename).orElse(null));
getFileUploadStrategy(fileUploadType.getFileStorageType()) getFileUploadStrategy(FileStorageType.valueOf(uploadStorageType))
.operate(multipartFile, subPath, createFilename); .operate(multipartFile, subPath, createFilename);
return Optional.of( return Optional.of(
@@ -128,6 +131,6 @@ public class SaveToStorageService implements SaveToStoragePortIn {
() -> () ->
new NoSuchElementException( new NoSuchElementException(
String.format("No file upload strategy found: %s", String.format("No file upload strategy found: %s",
fileStorageType.name()))); fileStorageType.getName())));
} }
} }

View File

@@ -0,0 +1,66 @@
package app.module.core.usecase.file.updateFile.adapters.persistence;
import app.module.core.config.adapters.persistence.entity.UploadFile;
import app.module.core.config.application.annotation.DeleteCommand;
import app.module.core.config.application.annotation.UpdateCommand;
import app.module.core.config.application.enums.FileUploadType;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.config.application.util.SftpFileDeleteUtil;
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortOut;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Slf4j
@Repository
@RequiredArgsConstructor
class UpdateFileDao implements UpdateFilePortOut {
private final UpdateFileMapper mapper;
private final SftpFileDeleteUtil sftpFileDeleteUtil;
@Override
@DeleteCommand
public void operate(UpdateFileCmd command) {
List<UploadFileDto> deletedFileList = mapper.findDeleteFileList(new UpdateUploadFileParam(
command.getId(),
command.getFileMappingIds(),
command.getType().getName()
));
for (UploadFileDto file : deletedFileList) {
try {
sftpFileDeleteUtil.deleteRealFile(file);
} catch (JSchException | SftpException e) {
log.error("Failed to delete file from SFTP for mapping ID {}: {}", file.getId(), e.getMessage(), e);
throw new RuntimeException("Failed to delete file from SFTP", e);
} catch (Exception e) {
log.error("Unexpected error while deleting file for mapping ID {}: {}", file.getId(), e.getMessage(), e);
throw new RuntimeException("Unexpected error while deleting file", e);
}
}
if (!deletedFileList.isEmpty()) {
mapper.deleteFile(
new UpdateUploadFileParam(
command.getId(),
deletedFileList.stream().map(UploadFileDto::getId).toList(),
command.getType().getName()));
}
command.getFileMappingIds().forEach(fileId -> mapper.updateFile(new UploadFileDto(fileId, command.getId(),command.getType().getName())));
}
}

View File

@@ -0,0 +1,14 @@
package app.module.core.usecase.file.updateFile.adapters.persistence;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UpdateFileMapper {
List<UploadFileDto> findDeleteFileList(UpdateUploadFileParam uploadFile);
void deleteFile(UpdateUploadFileParam uploadFile);
void updateFile(UploadFileDto uploadFile);
}

View File

@@ -0,0 +1,8 @@
package app.module.core.usecase.file.updateFile.ports;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
public interface UpdateFilePortIn {
void operate(UpdateFileCmd command);
}

View File

@@ -0,0 +1,8 @@
package app.module.core.usecase.file.updateFile.ports;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
public interface UpdateFilePortOut {
void operate(UpdateFileCmd command);
}

View File

@@ -0,0 +1,20 @@
package app.module.core.usecase.file.updateFile.ports.application;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortIn;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortOut;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class UpdateFileService implements UpdateFilePortIn {
private final UpdateFilePortOut portOut;
@Override
public void operate(UpdateFileCmd command) {
portOut.operate(command);
}
}

View File

@@ -0,0 +1,19 @@
package app.module.core.usecase.file.updateFile.ports.application.domain;
import app.module.core.config.application.enums.FileUploadType;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class UpdateFileCmd {
private Long id;
private List<Long> fileMappingIds;
private FileUploadType type;
}

View File

@@ -0,0 +1,18 @@
package app.module.core.usecase.file.updateFile.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import app.module.core.config.application.enums.FileUploadType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Setter
@Getter
@AllArgsConstructor
public class UpdateUploadFileParam extends AuditCommand {
private Long id;
private List<Long> fileMappingIds;
private String type;
}

View File

@@ -0,0 +1,43 @@
package app.module.core.usecase.file.updateFile.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import app.module.core.config.adapters.persistence.component.AuditEntity;
import app.module.core.config.application.enums.FileUploadType;
import lombok.*;
import java.time.LocalDateTime;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class UploadFileDto extends AuditCommand {
private Long id;
private Long mappingId;
private String type;
private String path;
private String name;
private String originName;
private Long fileLength;
private LocalDateTime updatedAt;
private String updatedBy;
public UploadFileDto(Long id) {
this.id = id;
}
public UploadFileDto(Long id, Long mappingId, String type) {
this.id = id;
this.mappingId = mappingId;
this.type = type;
}
}

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.getAttachment.adapters.web; package app.module.core.usecase.getAttachment.adapters.web;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.getFile.ports.GetFilePortIn; import app.module.core.usecase.file.getFile.ports.GetFilePortIn;
import app.module.core.usecase.file.getFile.ports.application.domain.GetFile; import app.module.core.usecase.file.getFile.ports.application.domain.GetFile;
import app.module.core.usecase.file.getFile.ports.application.domain.GetFileCmd; import app.module.core.usecase.file.getFile.ports.application.domain.GetFileCmd;
@@ -27,6 +28,8 @@ class GetAttachmentController {
private String cloudFrontDomain; private String cloudFrontDomain;
@Value("${app.aws.s3.bucketFolder:null}") @Value("${app.aws.s3.bucketFolder:null}")
private String bucketFolder; private String bucketFolder;
@Value("${path.upload.storage}")
private String uploadStorageType;
@GetMapping(path = "/content-disposition/attachment/{fileId}") @GetMapping(path = "/content-disposition/attachment/{fileId}")
ResponseEntity<?> operate(@PathVariable Long fileId) throws MalformedURLException { ResponseEntity<?> operate(@PathVariable Long fileId) throws MalformedURLException {
@@ -55,7 +58,7 @@ class GetAttachmentController {
UrlResource resource = null; UrlResource resource = null;
switch (getFile.getType().getFileStorageType()) { switch (FileStorageType.valueOf(uploadStorageType)) {
case LOCAL: case LOCAL:
String filePath = String filePath =
Paths.get(publicPath, getFile.getPath(), getFile.getName()) Paths.get(publicPath, getFile.getPath(), getFile.getName())

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.uri.save.ports.application; package app.module.core.usecase.uri.save.ports.application;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.config.application.enums.FileUploadType; import app.module.core.config.application.enums.FileUploadType;
import app.module.core.config.application.exception.AlreadyExistItemException; import app.module.core.config.application.exception.AlreadyExistItemException;
import app.module.core.config.application.util.MessageUtil; import app.module.core.config.application.util.MessageUtil;
@@ -11,6 +12,7 @@ import app.module.core.usecase.uri.save.ports.URISavePortIn;
import app.module.core.usecase.uri.save.ports.URISavePortOut; import app.module.core.usecase.uri.save.ports.URISavePortOut;
import app.module.core.usecase.uri.save.ports.application.domain.URISaveCommand; import app.module.core.usecase.uri.save.ports.application.domain.URISaveCommand;
import app.module.core.usecase.uri.view.ports.URIViewPortIn; import app.module.core.usecase.uri.view.ports.URIViewPortIn;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException; import java.io.IOException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -28,6 +30,8 @@ class URISaveService implements URISavePortIn {
private final MessageUtil messageUtil; private final MessageUtil messageUtil;
private final SaveToStoragePortIn saveToStoragePortIn; private final SaveToStoragePortIn saveToStoragePortIn;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Transactional @Transactional
@CacheEvict( @CacheEvict(
@@ -59,7 +63,7 @@ class URISaveService implements URISavePortIn {
uri.setOgImage( uri.setOgImage(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
ogImg.getType().getFileStorageType(), ogImg.getPath(), ogImg.getName())); FileStorageType.valueOf(uploadStorageType), ogImg.getPath(), ogImg.getName()));
} }
return uriSavePortOut.connect(uri); return uriSavePortOut.connect(uri);

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.user.findUser.ports.application; package app.module.core.usecase.user.findUser.ports.application;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import app.module.core.usecase.user.findUser.ports.FindUserPortIn; import app.module.core.usecase.user.findUser.ports.FindUserPortIn;
import app.module.core.usecase.user.findUser.ports.FindUserPortOut; import app.module.core.usecase.user.findUser.ports.FindUserPortOut;
@@ -8,6 +9,7 @@ import app.module.core.usecase.user.findUser.ports.application.domain.FindUser;
import app.module.core.usecase.user.findUser.ports.application.domain.FindUserCmd; import app.module.core.usecase.user.findUser.ports.application.domain.FindUserCmd;
import java.util.Optional; import java.util.Optional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@@ -17,6 +19,9 @@ class FindUserService implements FindUserPortIn {
private final FindUserPortOut portOut; private final FindUserPortOut portOut;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
public Optional<FindUser> operate(FindUserCmd command) { public Optional<FindUser> operate(FindUserCmd command) {
return portOut return portOut
@@ -29,14 +34,14 @@ class FindUserService implements FindUserPortIn {
// 참조 URL 전달 // 참조 URL 전달
profileImg.setReferURL( profileImg.setReferURL(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
profileImg.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
profileImg.getPath(), profileImg.getPath(),
profileImg.getName())); profileImg.getName()));
// attachment URL 전달 // attachment URL 전달
profileImg.setAttachmentURL( profileImg.setAttachmentURL(
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
profileImg.getType().getFileStorageType(), profileImg.getId())); FileStorageType.valueOf(uploadStorageType), profileImg.getId()));
} }
return Optional.of(findUser); return Optional.of(findUser);

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="app.module.core.usecase.file.updateFile.adapters.persistence.UpdateFileMapper">
<select id="findDeleteFileList" resultType="app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto">
SELECT file_length,
id,
name,
origin_name,
path,
type,
mapping_id
FROM upload_file
WHERE type = #{type} and mapping_id = #{id} and is_deleted = false
<if test="fileMappingIds != null and fileMappingIds.size() > 0">
and id NOT IN (
<foreach collection="fileMappingIds" item="fileId" separator="," >
#{fileId}
</foreach>
)
</if>
</select>
<update id="deleteFile">
UPDATE upload_file
SET
<include refid="common.fields.DeleteBaseSet"/>
WHERE type = #{type} and mapping_id = #{id} and is_deleted = false
<if test="fileMappingIds != null and fileMappingIds.size() > 0">
and id IN (
<foreach collection="fileMappingIds" item="fileId" separator="," >
#{fileId}
</foreach>
)
</if>
</update>
<update id="updateFile" >
UPDATE upload_file
SET mapping_id = #{mappingId},
type = #{type},
<include refid="common.fields.UpdateBaseSet"/>
WHERE id = #{id}
</update>
</mapper>

View File

@@ -83,7 +83,8 @@ COMMENT ON COLUMN role.is_deleted IS '삭제 여부';
CREATE SEQUENCE upload_file_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE; CREATE SEQUENCE upload_file_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
CREATE TABLE upload_file ( CREATE TABLE upload_file (
id bigint DEFAULT nextval('upload_file_seq') NOT NULL, -- 파일 ID (PK) id int8 DEFAULT nextval('upload_file_seq') NOT NULL, -- 파일 ID (PK)
mapping_id int8, -- 파일 매핑 ID
name varchar(255), -- 시스템 저장 파일명 name varchar(255), -- 시스템 저장 파일명
origin_name varchar(255), -- 원본 파일명 origin_name varchar(255), -- 원본 파일명
path varchar(255), -- 파일 경로 path varchar(255), -- 파일 경로
@@ -115,6 +116,7 @@ CREATE TABLE upload_file (
COMMENT ON TABLE upload_file IS '업로드 파일 정보 테이블'; COMMENT ON TABLE upload_file IS '업로드 파일 정보 테이블';
COMMENT ON COLUMN upload_file.id IS '파일 ID (PK)'; COMMENT ON COLUMN upload_file.id IS '파일 ID (PK)';
COMMENT ON COLUMN upload_file.mapping_id IS '파일 매핑 ID';
COMMENT ON COLUMN upload_file.name IS '시스템 저장 파일명'; COMMENT ON COLUMN upload_file.name IS '시스템 저장 파일명';
COMMENT ON COLUMN upload_file.origin_name IS '원본 파일명'; COMMENT ON COLUMN upload_file.origin_name IS '원본 파일명';
COMMENT ON COLUMN upload_file.path IS '파일 경로'; COMMENT ON COLUMN upload_file.path IS '파일 경로';
@@ -1865,37 +1867,6 @@ COMMENT ON COLUMN notice.is_deleted IS '삭제여부';
-- ============================================
-- TABLE : notice_has_upload_file
-- DESC : 공지사항 파일 매핑 테이블
-- ============================================
CREATE TABLE notice_has_upload_file (
upload_files_id bigint NOT NULL, -- 업로드 파일 ID (FK)
notice_id varchar(255) NOT NULL, -- 공지사항 ID (FK)
created_at timestamp(6), -- 생성일
created_by varchar(255), -- 생성자
updated_at timestamp(6), -- 수정일
updated_by varchar(255), -- 수정자
deleted_at timestamp(6), -- 삭제일
deleted_by varchar(255), -- 삭제자
is_deleted boolean DEFAULT false NOT NULL -- 삭제 여부
);
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__notice FOREIGN KEY (notice_id) REFERENCES notice(id);
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__upload_file FOREIGN KEY (upload_files_id) REFERENCES upload_file(id);
COMMENT ON TABLE notice_has_upload_file IS '공지사항 파일 매핑 테이블';
COMMENT ON COLUMN notice_has_upload_file.upload_files_id IS '업로드 파일 ID';
COMMENT ON COLUMN notice_has_upload_file.notice_id IS '공지사항 ID';
COMMENT ON COLUMN notice_has_upload_file.created_at IS '생성일';
COMMENT ON COLUMN notice_has_upload_file.created_by IS '생성자';
COMMENT ON COLUMN notice_has_upload_file.updated_at IS '수정일';
COMMENT ON COLUMN notice_has_upload_file.updated_by IS '수정자';
COMMENT ON COLUMN notice_has_upload_file.deleted_at IS '삭제일';
COMMENT ON COLUMN notice_has_upload_file.deleted_by IS '삭제자';
COMMENT ON COLUMN notice_has_upload_file.is_deleted IS '삭제여부';
-- ============================================ -- ============================================