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 12cceb1..b2002af 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 @@ -9,9 +9,6 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.ArrayList; -import java.util.List; - @Getter @Entity @Table(name = "project_image") @@ -49,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; /** * 속한 폴더 @@ -62,7 +59,7 @@ public class Image extends BaseEntity { /** * 이미지에 연결된 레이블 */ - @OneToOne(mappedBy = "image", cascade = CascadeType.ALL, orphanRemoval = true) + @OneToOne(mappedBy = "image", fetch = FetchType.LAZY, 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 93f66a7..f3253a0 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,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; public enum LabelStatus { - PENDING, + Pending, IN_PROGRESS, NEED_REVIEW, COMPLETED; diff --git a/backend/src/main/java/com/worlabel/domain/image/repository/ImageRepository.java b/backend/src/main/java/com/worlabel/domain/image/repository/ImageRepository.java index 2e70391..ddb86b3 100644 --- a/backend/src/main/java/com/worlabel/domain/image/repository/ImageRepository.java +++ b/backend/src/main/java/com/worlabel/domain/image/repository/ImageRepository.java @@ -12,10 +12,8 @@ public interface ImageRepository extends JpaRepository { Optional findByIdAndFolderId(Long imageId, Integer folderId); - // TODO: N + 1 @Query("select i from Image i " + - "join fetch i.folder f " + - "join fetch f.project p " + - "where p.id = :projectId") + "join fetch i.label l " + + "where i.folder.project.id = :projectId") List findImagesByProjectId(@Param("projectId") Integer projectId); } diff --git a/backend/src/main/java/com/worlabel/domain/label/controller/LabelController.java b/backend/src/main/java/com/worlabel/domain/label/controller/LabelController.java index dfde93f..ac7b67b 100644 --- a/backend/src/main/java/com/worlabel/domain/label/controller/LabelController.java +++ b/backend/src/main/java/com/worlabel/domain/label/controller/LabelController.java @@ -26,7 +26,6 @@ public class LabelController { private final LabelService labelService; - @Operation(summary = "프로젝트 단위 오토레이블링", description = "해당 프로젝트 이미지를 오토레이블링합니다.") @SwaggerApiSuccess(description = "해당 프로젝트가 오토 레이블링 됩니다.") @SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR}) @@ -51,7 +50,4 @@ public class LabelController { labelService.save(imageId); return SuccessResponse.empty(); } - - - } 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 a4f7aff..124e190 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 @@ -34,14 +34,6 @@ public class Label extends BaseEntity { @JoinColumn(name = "image_id") private Image image; - /** - * 속한 카테고리 - * TODO: 한 레이블 카테고리에 속한걸 찾는데에 Json파일에 담기 때문에 카테고리는 Label Entity에 없어도 될 것 같음 - */ -// @ManyToOne(fetch = FetchType.LAZY) -// @JoinColumn(name = "label_category_id") -// private LabelCategory labelCategory; - public static Label of(String jsonUrl, Image image) { Label label = new Label(); label.url = jsonUrl; @@ -49,4 +41,7 @@ public class Label extends BaseEntity { return label; } + public void changeUrl(String newUrl){ + + } } diff --git a/backend/src/main/java/com/worlabel/domain/label/repository/LabelRepository.java b/backend/src/main/java/com/worlabel/domain/label/repository/LabelRepository.java index 1f84962..cdf4641 100644 --- a/backend/src/main/java/com/worlabel/domain/label/repository/LabelRepository.java +++ b/backend/src/main/java/com/worlabel/domain/label/repository/LabelRepository.java @@ -8,4 +8,6 @@ import java.util.Optional; public interface LabelRepository extends JpaRepository { Optional