From 6497982bc5c2be44c67edf1bfcffa4da0f46f281 Mon Sep 17 00:00:00 2001 From: Wonjun You <59856002+wonjunYou@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:42:39 +0900 Subject: [PATCH] =?UTF-8?q?[DDING-044]=20FileMetaData=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EC=BF=BC=EB=A6=AC=EC=97=90=EC=84=9C=20id=20=EC=98=A4?= =?UTF-8?q?=EB=A6=84=EC=B0=A8=EC=88=9C=20=EC=A0=95=EB=A0=AC=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EC=B6=94=EA=B0=80=20(#192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/FileMetaDataRepository.java | 14 ++++++++++++++ .../filemetadata/service/FileMetaDataService.java | 3 +++ .../service/FileMetaDataServiceImpl.java | 7 +++++++ .../notice/service/FacadeNoticeServiceImpl.java | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/repository/FileMetaDataRepository.java b/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/repository/FileMetaDataRepository.java index 3e3c477f..74052782 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/repository/FileMetaDataRepository.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/repository/FileMetaDataRepository.java @@ -42,4 +42,18 @@ where id in (:ids) and file_status != 'DELETED' """, nativeQuery = true) List findByIdIn(@Param("ids") List ids); + + @Query(""" + select fmd from FileMetaData fmd + where fmd.domainType = :domainType + and fmd.entityId = :entityId + and fmd.fileStatus = :fileStatus + and fmd.fileStatus != 'DELETED' + order by fmd.id asc + """) + List findAllByDomainTypeAndEntityIdWithFileStatusOrderedAsc( + @Param("domainType") DomainType domainType, + @Param("entityId") Long entityId, + @Param("fileStatus") FileStatus fileStatus + ); } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataService.java b/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataService.java index 75b9766d..2bb421dd 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataService.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataService.java @@ -11,6 +11,9 @@ public interface FileMetaDataService { List getCoupledAllByDomainTypeAndEntityId(DomainType domainType, Long entityId); + List getCoupledAllByDomainTypeAndEntityIdOrderedAsc(DomainType domainType, + Long entityId); + void updateStatusToCoupled(List ids, DomainType domainType, Long entityId); void updateStatusToCoupled(String id, DomainType domainType, Long entityId); diff --git a/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataServiceImpl.java index b5b54853..b50ad12b 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/filemetadata/service/FileMetaDataServiceImpl.java @@ -36,6 +36,13 @@ public List getCoupledAllByDomainTypeAndEntityId(DomainType domain return fileMetaDataRepository.findAllByDomainTypeAndEntityIdWithFileStatus(domainType, entityId, COUPLED); } + @Override + public List getCoupledAllByDomainTypeAndEntityIdOrderedAsc(DomainType domainType, + Long entityId) { + return fileMetaDataRepository.findAllByDomainTypeAndEntityIdWithFileStatusOrderedAsc( + domainType, entityId, COUPLED); + } + @Transactional @Override public void updateStatusToCoupled(List ids, DomainType domainType, Long entityId) { diff --git a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java index b5803ad8..13e32fc0 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java @@ -41,7 +41,7 @@ public NoticeQuery getNotice(Long noticeId) { Notice notice = noticeService.getById(noticeId); List imageUrlQueries = fileMetaDataService - .getCoupledAllByDomainTypeAndEntityId(DomainType.NOTICE_IMAGE, noticeId) + .getCoupledAllByDomainTypeAndEntityIdOrderedAsc(DomainType.NOTICE_IMAGE, noticeId) .stream() .map(fileMetaData -> s3FileService.getUploadedFileUrl(fileMetaData.getFileKey())) .toList();