Feat: 레이블 저장시 상태 변경

This commit is contained in:
김용수 2024-09-26 01:30:48 +09:00
parent 4e39e6d08c
commit 12969a02f2
2 changed files with 7 additions and 0 deletions

View File

@ -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;
@ -254,6 +255,8 @@ public class ImageService {
String dataPath = image.getDataPath();
s3UploadService.uploadJson(data, dataPath);
image.updateStatus(LabelStatus.IN_PROGRESS);
imageRepository.save(image);
}
private String getExtension(final MultipartFile file) {

View File

@ -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<AutoLabelingResult> 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);
}
}