From 4484d700938d4ad718f8d37ccdb060b0d140c08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8E=E1=85=AC=E1=84=8E=E1=85=A5=E1=86=AF=E1=84=8C?= =?UTF-8?q?=E1=85=B5=E1=86=AB?= Date: Mon, 9 Dec 2024 14:23:35 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=8E=AB=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=EC=8B=9C=20User=EC=9D=98=20is=5Fregistered=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=EC=9D=84=200=EC=97=90=EC=84=9C=201=EB=A1=9C=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/petmatz/domain/pet/PetServiceImpl.java | 16 +++++++--------- .../com/petmatz/domain/user/entity/User.java | 7 +++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/petmatz/domain/pet/PetServiceImpl.java b/src/main/java/com/petmatz/domain/pet/PetServiceImpl.java index 4fd9ba7..c6a7ded 100644 --- a/src/main/java/com/petmatz/domain/pet/PetServiceImpl.java +++ b/src/main/java/com/petmatz/domain/pet/PetServiceImpl.java @@ -8,29 +8,21 @@ import com.petmatz.domain.pet.dto.PetServiceDto; import com.petmatz.domain.pet.dto.PetServiceDtoFactory; import com.petmatz.domain.pet.dto.PetUpdateResponse; -import com.petmatz.domain.pet.exception.ImageErrorCode; -import com.petmatz.domain.pet.exception.ImageServiceException; import com.petmatz.domain.pet.exception.PetErrorCode; import com.petmatz.domain.pet.exception.PetServiceException; import com.petmatz.domain.user.entity.User; +import com.petmatz.domain.user.repository.UserRepository; import lombok.RequiredArgsConstructor; -import lombok.Value; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.UUID; import java.util.stream.Collectors; import static com.petmatz.domain.pet.exception.PetErrorCode.PET_NOT_FOUND; @@ -42,6 +34,7 @@ public class PetServiceImpl implements PetService{ private final AwsClient awsClient; private final PetRepository repository; + private final UserRepository userRepository; private final ObjectMapper objectMapper = new ObjectMapper(); private final String uploadDir = System.getProperty("user.dir") + "/uploads/"; @@ -104,6 +97,11 @@ public PetSaveResponse savePet(User user, PetServiceDto dto) throws MalformedURL .build(); Long id = repository.save(pet).getId(); + + // User의 isRegistered 상태 업데이트 + user.markAsRegistered(); + userRepository.save(user); + return PetSaveResponse.of(id, resultImgURL); } diff --git a/src/main/java/com/petmatz/domain/user/entity/User.java b/src/main/java/com/petmatz/domain/user/entity/User.java index 9797298..987a843 100644 --- a/src/main/java/com/petmatz/domain/user/entity/User.java +++ b/src/main/java/com/petmatz/domain/user/entity/User.java @@ -170,4 +170,11 @@ public void checkLatitudeLongitude() { // (희수 : 예외나 위도 경도 범 } } } + + public void markAsRegistered() { + if (Boolean.TRUE.equals(this.isRegistered)) { + return; // 이미 등록된 경우 아무 작업도 하지 않음 + } + this.isRegistered = true; // 등록 상태로 변경 + } }