Skip to content

Commit

Permalink
[DDING-044] FileMetaData 조회 쿼리에서 id 오름차순 정렬 조건 추가 (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou authored Nov 27, 2024
1 parent 92aa824 commit 6497982
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@ where id in (:ids)
and file_status != 'DELETED'
""", nativeQuery = true)
List<FileMetaData> findByIdIn(@Param("ids") List<UUID> 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<FileMetaData> findAllByDomainTypeAndEntityIdWithFileStatusOrderedAsc(
@Param("domainType") DomainType domainType,
@Param("entityId") Long entityId,
@Param("fileStatus") FileStatus fileStatus
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public interface FileMetaDataService {

List<FileMetaData> getCoupledAllByDomainTypeAndEntityId(DomainType domainType, Long entityId);

List<FileMetaData> getCoupledAllByDomainTypeAndEntityIdOrderedAsc(DomainType domainType,
Long entityId);

void updateStatusToCoupled(List<String> ids, DomainType domainType, Long entityId);

void updateStatusToCoupled(String id, DomainType domainType, Long entityId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public List<FileMetaData> getCoupledAllByDomainTypeAndEntityId(DomainType domain
return fileMetaDataRepository.findAllByDomainTypeAndEntityIdWithFileStatus(domainType, entityId, COUPLED);
}

@Override
public List<FileMetaData> getCoupledAllByDomainTypeAndEntityIdOrderedAsc(DomainType domainType,
Long entityId) {
return fileMetaDataRepository.findAllByDomainTypeAndEntityIdWithFileStatusOrderedAsc(
domainType, entityId, COUPLED);
}

@Transactional
@Override
public void updateStatusToCoupled(List<String> ids, DomainType domainType, Long entityId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public NoticeQuery getNotice(Long noticeId) {
Notice notice = noticeService.getById(noticeId);

List<UploadedFileUrlQuery> imageUrlQueries = fileMetaDataService
.getCoupledAllByDomainTypeAndEntityId(DomainType.NOTICE_IMAGE, noticeId)
.getCoupledAllByDomainTypeAndEntityIdOrderedAsc(DomainType.NOTICE_IMAGE, noticeId)
.stream()
.map(fileMetaData -> s3FileService.getUploadedFileUrl(fileMetaData.getFileKey()))
.toList();
Expand Down

0 comments on commit 6497982

Please sign in to comment.