From 23c72486dab860dfab0b30b81171288fbbb940c3 Mon Sep 17 00:00:00 2001 From: jjikky Date: Mon, 2 Sep 2024 16:53:10 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=EC=98=A4=EB=B8=8C=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=82=AD=EC=A0=9C=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?dto=20sharer=20data=20type=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daobe/objet/application/dto/ObjetCreateRequestDto.java | 4 +++- .../daobe/objet/application/dto/ObjetUpdateRequestDto.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/daobe/objet/application/dto/ObjetCreateRequestDto.java b/src/main/java/com/example/daobe/objet/application/dto/ObjetCreateRequestDto.java index 35d808f5..3ac70187 100644 --- a/src/main/java/com/example/daobe/objet/application/dto/ObjetCreateRequestDto.java +++ b/src/main/java/com/example/daobe/objet/application/dto/ObjetCreateRequestDto.java @@ -1,7 +1,9 @@ package com.example.daobe.objet.application.dto; +import java.util.List; + public record ObjetCreateRequestDto( - String sharers, + List sharers, String name, String description, String type, diff --git a/src/main/java/com/example/daobe/objet/application/dto/ObjetUpdateRequestDto.java b/src/main/java/com/example/daobe/objet/application/dto/ObjetUpdateRequestDto.java index c67df7ed..2497b9ea 100644 --- a/src/main/java/com/example/daobe/objet/application/dto/ObjetUpdateRequestDto.java +++ b/src/main/java/com/example/daobe/objet/application/dto/ObjetUpdateRequestDto.java @@ -1,11 +1,12 @@ package com.example.daobe.objet.application.dto; +import java.util.List; import lombok.Builder; @Builder public record ObjetUpdateRequestDto( Long objetId, - String sharers, + List sharers, String name, String description, String objetImage From ec9eed2e4f7abb4f10aa5d87311dc5de693e6013 Mon Sep 17 00:00:00 2001 From: jjikky Date: Mon, 2 Sep 2024 16:53:25 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=EC=98=A4=EB=B8=8C=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=82=AD=EC=A0=9C=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20sharer=20data=20type=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daobe/objet/application/ObjetService.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/example/daobe/objet/application/ObjetService.java b/src/main/java/com/example/daobe/objet/application/ObjetService.java index ef1c40e1..36159c58 100644 --- a/src/main/java/com/example/daobe/objet/application/ObjetService.java +++ b/src/main/java/com/example/daobe/objet/application/ObjetService.java @@ -29,8 +29,6 @@ import com.example.daobe.user.domain.User; import com.example.daobe.user.domain.repository.UserRepository; import com.example.daobe.user.exception.UserException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.Comparator; import java.util.List; @@ -75,7 +73,7 @@ public ObjetCreateResponseDto create(Long userId, ObjetCreateRequestDto request) .build(); objetRepository.save(objet); - List sharerIds = parseSharerData(request.sharers()); + List sharerIds = request.sharers(); sharerIds.add(userId); List objetSharers = manageSharers(objet, sharerIds, userId); @@ -97,7 +95,7 @@ public ObjetCreateResponseDto update(Long userId, Long objetId, ObjetUpdateReque } Set currentSharerIds = getCurrentSharerIds(findObjet); - List newSharerIds = parseSharerData(request.sharers()); + List newSharerIds = request.sharers(); manageAndSyncSharers(findObjet, currentSharerIds, newSharerIds, userId); objetRepository.save(findObjet); @@ -199,15 +197,6 @@ private Set getCurrentSharerIds(Objet findObjet) { .collect(Collectors.toSet()); } - private List parseSharerData(String sharers) { - try { - return objectMapper.readValue(sharers, new TypeReference<>() { - }); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - private List manageSharers(Objet objet, List sharerIds, Long userId) { return sharerIds.stream() .map(sharerId -> { From c45170cd56c2b3d23a5ba4a804dc37a93c99c8c2 Mon Sep 17 00:00:00 2001 From: jjikky Date: Mon, 2 Sep 2024 17:00:24 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20objectMapper=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/daobe/objet/application/ObjetService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/example/daobe/objet/application/ObjetService.java b/src/main/java/com/example/daobe/objet/application/ObjetService.java index 36159c58..a5059a60 100644 --- a/src/main/java/com/example/daobe/objet/application/ObjetService.java +++ b/src/main/java/com/example/daobe/objet/application/ObjetService.java @@ -29,7 +29,6 @@ import com.example.daobe.user.domain.User; import com.example.daobe.user.domain.repository.UserRepository; import com.example.daobe.user.exception.UserException; -import com.fasterxml.jackson.databind.ObjectMapper; import java.util.Comparator; import java.util.List; import java.util.Set; @@ -53,7 +52,6 @@ public class ObjetService { private final ChatService chatRoomService; private final ObjetCallRepository objetCallRepository; private final ApplicationEventPublisher eventPublisher; - private final ObjectMapper objectMapper = new ObjectMapper(); @Transactional public ObjetCreateResponseDto create(Long userId, ObjetCreateRequestDto request) {