diff --git a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java index 1b6ff4e..1d3c4a3 100644 --- a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java +++ b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java @@ -3,6 +3,7 @@ package com.worlabel.domain.image.service; import com.worlabel.domain.folder.entity.Folder; import com.worlabel.domain.folder.repository.FolderRepository; import com.worlabel.domain.image.entity.Image; +import com.worlabel.domain.image.entity.LabelStatus; import com.worlabel.domain.image.entity.dto.*; import com.worlabel.domain.image.repository.ImageRepository; import com.worlabel.domain.participant.entity.PrivilegeType; @@ -19,7 +20,9 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -131,6 +134,8 @@ public class ImageService { Image image = imageRepository.findById(imageId) .orElseThrow(() -> new CustomException(ErrorCode.DATA_NOT_FOUND)); String dataPath = image.getDataPath(); + image.updateStatus(LabelStatus.COMPLETED); + imageRepository.save(image); s3UploadService.uploadJson(labelRequest.getData(), dataPath); } diff --git a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java index 3b67b8e..d8eec70 100644 --- a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java +++ b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java @@ -4,6 +4,7 @@ import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.google.gson.reflect.TypeToken; import com.worlabel.domain.image.entity.Image; +import com.worlabel.domain.image.entity.LabelStatus; import com.worlabel.domain.image.repository.ImageRepository; import com.worlabel.domain.labelcategory.entity.ProjectCategory; import com.worlabel.domain.member.entity.Member; @@ -185,12 +186,15 @@ public class ProjectService { } // TODO: 트랜잭션 설정 + // TODO: 어떤 상황까지 덮어쓸껀지 물어보기 @Transactional public void saveAutoLabelList(final List resultList) { for(AutoLabelingResult result: resultList) { Image image = getImage(result.getImageId()); + if(image.getStatus() == LabelStatus.SAVE) continue; String dataPath = image.getDataPath(); s3UploadService.uploadJson(result.getData(), dataPath); + image.updateStatus(LabelStatus.IN_PROGRESS); } }