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..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,9 +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; import java.util.Set; @@ -55,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) { @@ -75,7 +71,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 +93,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 +195,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 -> { 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