diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java index ea2fc7f..156525c 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java @@ -26,7 +26,7 @@ public class SeedController { private final SeedService seedService; - @PostMapping("/cave/{caveId}/seed") + @PostMapping("/member/{memberId}/cave/{caveId}/seed") @ResponseStatus(HttpStatus.CREATED) @Operation(summary = "SeedPost", description = "씨앗 생성 API입니다.") public ApiResponse createSeed(@PathVariable("caveId") Long caveId, @Valid @RequestBody SeedCreateRequestDto seedCreateRequestDto) { @@ -71,11 +71,11 @@ public ApiResponse> getSeedListByCave(@PathVariable return ApiResponse.success(SuccessStatus.GET_SEED_LIST_BY_CAVE, seedService.getSeedListByCave(caveId)); } - @GetMapping("seed/list") + @GetMapping("member/{memberId}/seed/list") @ResponseStatus(HttpStatus.OK) @Operation(summary = "SeedListGet", description = "전체 씨앗 리스트를 조회하는 API입니다.") - public ApiResponse> getSeedList() { - return ApiResponse.success(SuccessStatus.GET_SEED_LIST, seedService.getSeedList()); + public ApiResponse> getSeedList(@PathVariable Long memberId) { + return ApiResponse.success(SuccessStatus.GET_SEED_LIST, seedService.getSeedList(memberId)); } @PatchMapping("seed/{seedId}/scrap/status") diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java index e50b397..5082f8a 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java @@ -31,6 +31,8 @@ public class Seed extends BaseTimeEntity { private String url; + private Long memberId; + @Column(name = "lock_date") private LocalDate lockDate; @@ -48,7 +50,7 @@ public class Seed extends BaseTimeEntity { private List actionPlans = new ArrayList<>(); @Builder - public Seed(String insight, String memo, String source, String url, Integer goalMonth, Cave cave) { + public Seed(String insight, String memo, String source, String url, Integer goalMonth, Cave cave, Long memberId) { this.insight = insight; this.memo = memo; this.source = source; @@ -57,6 +59,7 @@ public Seed(String insight, String memo, String source, String url, Integer goal this.isScraped = false; this.isLocked = false; this.cave = cave; + this.memberId = memberId; } public void updateSeed(String newInsight, String newMemo, String newSource, String newUrl) { diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java index e065b37..2f5f02a 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/repository/SeedRepository.java @@ -12,7 +12,7 @@ public interface SeedRepository extends JpaRepository { Optional findSeedById(Long seedId); List findByCaveIdOrderByIdDesc(Long caveId); - List findAllByOrderByIdDesc(); + List findByMemberIdOrderByIdDesc(Long memberId); default Seed findSeedByIdOrThrow(Long seedId) { return findSeedById(seedId) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java index d20bc7c..acad13e 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java @@ -43,6 +43,7 @@ public SeedCreateResponseDto createSeed(Long caveId, SeedCreateRequestDto seedCr .insight(seedCreateRequestDto.getInsight()) .source(seedCreateRequestDto.getSource()) .goalMonth(seedCreateRequestDto.getGoalMonth()) + .memberId(cave.getMember().getId()) .build(); Seed savedSeed = seedRepository.save(seed); return SeedCreateResponseDto.of(savedSeed.getId()); @@ -90,8 +91,8 @@ public List getSeedListByCave(Long caveId) { } @Override - public List getSeedList() { - return seedRepository.findAllByOrderByIdDesc().stream() + public List getSeedList(Long memberId) { + return seedRepository.findByMemberIdOrderByIdDesc(memberId).stream() .map(seed -> SeedListGetResponseDto.of(seed.getId(), seed.getInsight(), calculateRemainingDays(seed.getLockDate()), seed.getIsLocked(), seed.getIsScraped(), checkHasActionPlan(seed))) .collect(Collectors.toList()); diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java index 5a016b7..364ddaf 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java @@ -29,7 +29,7 @@ public interface SeedService { List getSeedListByCave(Long caveId); //* 씨앗 전체 리스트 조회 - List getSeedList(); + List getSeedList(Long memberId); //* 씨앗 스크랩 상태 변경 void toggleSeedScrapStatus(Long seedId);