From b5067b36cb65828b47f40930f9ce06016a571480 Mon Sep 17 00:00:00 2001 From: jisu Date: Wed, 6 Dec 2023 15:34:28 +0900 Subject: [PATCH 1/2] style: change field in CafeRegisterRequest DTO --- .../mocacong/server/dto/request/CafeRegisterRequest.java | 2 +- src/main/java/mocacong/server/service/CafeService.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java b/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java index 06151186..bd262102 100644 --- a/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java +++ b/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java @@ -10,7 +10,7 @@ @ToString public class CafeRegisterRequest { @NotBlank(message = "1012:공백일 수 없습니다.") - private String id; + private String mapId; @NotBlank(message = "1012:공백일 수 없습니다.") private String name; diff --git a/src/main/java/mocacong/server/service/CafeService.java b/src/main/java/mocacong/server/service/CafeService.java index d25af000..9b7bdb06 100644 --- a/src/main/java/mocacong/server/service/CafeService.java +++ b/src/main/java/mocacong/server/service/CafeService.java @@ -54,13 +54,13 @@ public class CafeService { @Transactional public void save(CafeRegisterRequest request) { - Cafe cafe = new Cafe(request.getId(), request.getName(), request.getRoadAddress(), request.getPhoneNumber()); + Cafe cafe = new Cafe(request.getMapId(), request.getName(), request.getRoadAddress(), request.getPhoneNumber()); - Optional cafeOptional = cafeRepository.findByMapId(request.getId()); + Optional cafeOptional = cafeRepository.findByMapId(request.getMapId()); try { - cafeRepository.findByMapId(request.getId()) + cafeRepository.findByMapId(request.getMapId()) .ifPresentOrElse( existedCafe -> existedCafe.updateCafeRoadAddress(request.getRoadAddress()), () -> cafeRepository.save(cafe) From 582f0eac88abced6e77b819f818820a06f2e0b7d Mon Sep 17 00:00:00 2001 From: jisu Date: Thu, 7 Dec 2023 14:37:47 +0900 Subject: [PATCH 2/2] style: delete unused code in save method --- src/main/java/mocacong/server/service/CafeService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/mocacong/server/service/CafeService.java b/src/main/java/mocacong/server/service/CafeService.java index 9b7bdb06..c6bb9778 100644 --- a/src/main/java/mocacong/server/service/CafeService.java +++ b/src/main/java/mocacong/server/service/CafeService.java @@ -31,7 +31,6 @@ import javax.persistence.EntityManager; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -56,9 +55,6 @@ public class CafeService { public void save(CafeRegisterRequest request) { Cafe cafe = new Cafe(request.getMapId(), request.getName(), request.getRoadAddress(), request.getPhoneNumber()); - - Optional cafeOptional = cafeRepository.findByMapId(request.getMapId()); - try { cafeRepository.findByMapId(request.getMapId()) .ifPresentOrElse(