diff --git a/BE/error/src/main/java/com/example/demo/filter/application/dto/AllFilterResponse.java b/BE/error/src/main/java/com/example/demo/filter/application/dto/AllFilterResponse.java index 4d0f292..2de54cf 100644 --- a/BE/error/src/main/java/com/example/demo/filter/application/dto/AllFilterResponse.java +++ b/BE/error/src/main/java/com/example/demo/filter/application/dto/AllFilterResponse.java @@ -1,5 +1,6 @@ package com.example.demo.filter.application.dto; +import com.example.demo.auth.persistence.MemberEntity; import com.example.demo.common.support.dto.AbstractDto; import lombok.AllArgsConstructor; import lombok.Builder; @@ -14,4 +15,5 @@ public class AllFilterResponse implements AbstractDto { private Long filterId; private String filterName; private String filterColor; + private MemberEntity member; } \ No newline at end of file diff --git a/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java index e7424d4..8ce4376 100644 --- a/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java +++ b/BE/error/src/main/java/com/example/demo/filter/application/model/converter/FilterResponseConverter.java @@ -26,6 +26,7 @@ public List toAllModel(List models) { .filterId(model.getFilterId()) .filterName(model.getFilterName()) .filterColor(model.getFilterColor()) + .member((model.getMember())) .build(); response.add(filter); } diff --git a/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java b/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java index 7d5d589..c0b8d42 100644 --- a/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java +++ b/BE/error/src/main/java/com/example/demo/filter/application/service/FilterService.java @@ -47,14 +47,14 @@ public CreateFilterResponse createFilter(final CreateFilterRequest request, fina } @Override - public List getFilter() { + public List getFilter(Long memberId) { // 필터를 조회할 때, 모든 데이터에서 param memberId와 같은 데이터만 조회하자 - List model = filterEntitiesByAll(); + List model = filterEntitiesByAll(memberId); return responseConverter.toAllModel(model); } - private List filterEntitiesByAll() { - Stream entities = filterRepository.streamAll(); + private List filterEntitiesByAll(Long memberId) { + Stream entities = filterRepository.streamAll(memberId); return entities .map(entityConverter::from) .collect(Collectors.toList()); diff --git a/BE/error/src/main/java/com/example/demo/filter/application/usecase/GetAllFilterUsecase.java b/BE/error/src/main/java/com/example/demo/filter/application/usecase/GetAllFilterUsecase.java index 1665f04..8fe03d6 100644 --- a/BE/error/src/main/java/com/example/demo/filter/application/usecase/GetAllFilterUsecase.java +++ b/BE/error/src/main/java/com/example/demo/filter/application/usecase/GetAllFilterUsecase.java @@ -7,5 +7,5 @@ import java.util.List; public interface GetAllFilterUsecase { - List getFilter(); + List getFilter(Long memberId); } diff --git a/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java index ebddeb5..a9b3c92 100644 --- a/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java +++ b/BE/error/src/main/java/com/example/demo/filter/persistence/FilterRepository.java @@ -2,12 +2,16 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.stream.Stream; @Repository public interface FilterRepository extends JpaRepository { - @Query("select p from FilterEntity p") Stream streamAll(); + //@Query("select p from FilterEntity p") Stream streamAll(); + @Query("select p from FilterEntity p where p.member = :memberId") + Stream streamAll(Long memberId); + } diff --git a/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java b/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java index 8dbe3e4..e556911 100644 --- a/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java +++ b/BE/error/src/main/java/com/example/demo/filter/presentation/FilterController.java @@ -38,9 +38,11 @@ public ApiResponse> createFilt } - @GetMapping - public ApiResponse>> getFilter() { - List response = getAllFilterUsecase.getFilter(); + @GetMapping("/{memberId}") + public ApiResponse>> getFilter( + @PathVariable("memberId") Long memberId + ) { + List response = getAllFilterUsecase.getFilter(memberId); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GET); }