From 6c2c0670abfd443c884265f877df1b4acc0b91db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Thu, 12 Sep 2024 18:00:10 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20:=20N=20+=201=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../folder/entity/dto/FolderResponse.java | 2 +- .../folder/repository/FolderRepository.java | 17 +++++++++++++++-- .../com/worlabel/domain/image/entity/Image.java | 4 ++-- .../domain/image/entity/LabelStatus.java | 5 +++-- .../com/worlabel/domain/label/entity/Label.java | 4 ---- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/com/worlabel/domain/folder/entity/dto/FolderResponse.java b/backend/src/main/java/com/worlabel/domain/folder/entity/dto/FolderResponse.java index 88e4d9d..b5c0fb5 100644 --- a/backend/src/main/java/com/worlabel/domain/folder/entity/dto/FolderResponse.java +++ b/backend/src/main/java/com/worlabel/domain/folder/entity/dto/FolderResponse.java @@ -45,7 +45,7 @@ public class FolderResponse { public static FolderResponse fromWithNeedReview(final Folder folder) { List images = folder.getImageList().stream() - .filter(image -> image.getStatus() == LabelStatus.NEED_REVIEW) + .filter(image -> image.getStatus() == LabelStatus.REVIEW_REQUEST) .map(ImageResponse::from) .toList(); diff --git a/backend/src/main/java/com/worlabel/domain/folder/repository/FolderRepository.java b/backend/src/main/java/com/worlabel/domain/folder/repository/FolderRepository.java index 32e43cd..83014c2 100644 --- a/backend/src/main/java/com/worlabel/domain/folder/repository/FolderRepository.java +++ b/backend/src/main/java/com/worlabel/domain/folder/repository/FolderRepository.java @@ -2,6 +2,8 @@ package com.worlabel.domain.folder.repository; import com.worlabel.domain.folder.entity.Folder; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -10,9 +12,20 @@ import java.util.Optional; @Repository public interface FolderRepository extends JpaRepository { - List findAllByProjectIdAndParentIsNull(Integer projectId); + @Query("SELECT f FROM Folder f " + + "LEFT JOIN FETCH f.imageList i " + + "LEFT JOIN FETCH i.label " + + "WHERE f.project.id = :projectId " + + "AND f.parent IS NULL ") + List findAllByProjectIdAndParentIsNull(@Param("projectId") Integer projectId); + + @Query("SELECT f FROM Folder f " + + "LEFT JOIN FETCH f.imageList i " + + "LEFT JOIN FETCH i.label " + + "WHERE f.project.id = :projectId " + + "AND f.id = :folderId") + Optional findAllByProjectIdAndId(@Param("projectId") Integer projectId, @Param("folderId") Integer folderId); - Optional findAllByProjectIdAndId(Integer projectId, Integer folderId); boolean existsByIdAndProjectId(Integer folderId, Integer projectId); } \ No newline at end of file diff --git a/backend/src/main/java/com/worlabel/domain/image/entity/Image.java b/backend/src/main/java/com/worlabel/domain/image/entity/Image.java index b2002af..19909df 100644 --- a/backend/src/main/java/com/worlabel/domain/image/entity/Image.java +++ b/backend/src/main/java/com/worlabel/domain/image/entity/Image.java @@ -46,7 +46,7 @@ public class Image extends BaseEntity { */ @Column(name = "status", nullable = false) @Enumerated(EnumType.STRING) - private LabelStatus status = LabelStatus.Pending; + private LabelStatus status = LabelStatus.PENDING; /** * 속한 폴더 @@ -59,7 +59,7 @@ public class Image extends BaseEntity { /** * 이미지에 연결된 레이블 */ - @OneToOne(mappedBy = "image", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + @OneToOne(fetch = FetchType.LAZY, mappedBy = "image", cascade = CascadeType.ALL, orphanRemoval = true) private Label label; private Image(final String imageTitle, final String imageUrl, final Integer order, final Folder folder) { diff --git a/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java b/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java index f3253a0..16ffbc5 100644 --- a/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java +++ b/backend/src/main/java/com/worlabel/domain/image/entity/LabelStatus.java @@ -4,9 +4,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; public enum LabelStatus { - Pending, + PENDING, IN_PROGRESS, - NEED_REVIEW, + SAVE, + REVIEW_REQUEST, COMPLETED; // 입력 값을 enum 값과 일치시키기 위해 대소문자 구분 없이 변환 diff --git a/backend/src/main/java/com/worlabel/domain/label/entity/Label.java b/backend/src/main/java/com/worlabel/domain/label/entity/Label.java index 124e190..bf5bbbe 100644 --- a/backend/src/main/java/com/worlabel/domain/label/entity/Label.java +++ b/backend/src/main/java/com/worlabel/domain/label/entity/Label.java @@ -40,8 +40,4 @@ public class Label extends BaseEntity { label.image = image; return label; } - - public void changeUrl(String newUrl){ - - } }