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 e92b102..9fd8ee7 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 @@ -6,7 +6,7 @@ import com.example.growthookserver.api.seed.dto.response.SeedAlarmGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedCreateResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedDetailGetResponseDto; -import com.example.growthookserver.api.seed.dto.response.SeedListByCaveGetResponseDto; +import com.example.growthookserver.api.seed.dto.response.SeedListGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedMoveResponseDto; import com.example.growthookserver.api.seed.service.SeedService; import com.example.growthookserver.common.response.ApiResponse; @@ -16,7 +16,6 @@ import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; -import org.springframework.boot.actuate.autoconfigure.observation.ObservationProperties.Http; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -69,10 +68,17 @@ public ApiResponse moveSeed(@PathVariable Long seedId, @Val @GetMapping("/cave/{caveId}/seed/list") @ResponseStatus(HttpStatus.OK) @Operation(summary = "SeedListByCaveGet", description = "보관함별 씨앗 리스트를 조회하는 API입니다.") - public ApiResponse> getSeedListByCave(@PathVariable Long caveId) { + public ApiResponse> getSeedListByCave(@PathVariable Long caveId) { return ApiResponse.success(SuccessStatus.GET_SEED_LIST_BY_CAVE, seedService.getSeedListByCave(caveId)); } + @GetMapping("seed/list") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "SeedListGet", description = "전체 씨앗 리스트를 조회하는 API입니다.") + public ApiResponse> getSeedList() { + return ApiResponse.success(SuccessStatus.GET_SEED_LIST, seedService.getSeedList()); + } + @GetMapping("member/{memberId}/alarm") @ResponseStatus(HttpStatus.OK) @Operation(summary = "SeedAlarm", description = "기한이 3일 이내로 남은 씨앗에 대한 알림을 조회하는 API입니다.") diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedListByCaveGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedListGetResponseDto.java similarity index 91% rename from growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedListByCaveGetResponseDto.java rename to growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedListGetResponseDto.java index 427a3aa..ee20805 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedListByCaveGetResponseDto.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/dto/response/SeedListGetResponseDto.java @@ -8,7 +8,7 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(staticName = "of") -public class SeedListByCaveGetResponseDto { +public class SeedListGetResponseDto { private Long seedId; private String insight; private Long remainingDays; 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 b43d5c0..43f18c8 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,6 +12,8 @@ public interface SeedRepository extends JpaRepository { Optional findSeedById(Long seedId); List findByCaveIdOrderByIdDesc(Long caveId); + List findAllByOrderByIdDesc(); + default Seed findSeedByIdOrThrow(Long seedId) { return findSeedById(seedId) .orElseThrow(()-> new NotFoundException(ErrorStatus.NOT_FOUND_SEED.getMessage())); 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 e407f31..38b43ac 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 @@ -11,7 +11,7 @@ import com.example.growthookserver.api.seed.dto.response.SeedAlarmGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedCreateResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedDetailGetResponseDto; -import com.example.growthookserver.api.seed.dto.response.SeedListByCaveGetResponseDto; +import com.example.growthookserver.api.seed.dto.response.SeedListGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedMoveResponseDto; import com.example.growthookserver.api.seed.repository.SeedRepository; import com.example.growthookserver.api.seed.service.SeedService; @@ -86,9 +86,17 @@ public SeedMoveResponseDto moveSeed(Long seedId, SeedMoveRequestDto seedMoveRequ } @Override - public List getSeedListByCave(Long caveId) { + public List getSeedListByCave(Long caveId) { return seedRepository.findByCaveIdOrderByIdDesc(caveId).stream() - .map(seed -> SeedListByCaveGetResponseDto.of(seed.getId(), seed.getInsight(), calculateRemainingDays(seed.getLockDate()), + .map(seed -> SeedListGetResponseDto.of(seed.getId(), seed.getInsight(), calculateRemainingDays(seed.getLockDate()), + seed.getIsLocked(), seed.getIsScraped(), checkHasActionPlan(seed))) + .collect(Collectors.toList()); + } + + @Override + public List getSeedList() { + return seedRepository.findAllByOrderByIdDesc().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 c0f2466..a8bf33c 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 @@ -1,14 +1,12 @@ package com.example.growthookserver.api.seed.service; -import com.example.growthookserver.api.cave.dto.request.CaveCreateRequestDto; -import com.example.growthookserver.api.cave.dto.response.CaveCreateResponseDto; import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedUpdateRequestDto; import com.example.growthookserver.api.seed.dto.response.SeedAlarmGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedCreateResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedDetailGetResponseDto; -import com.example.growthookserver.api.seed.dto.response.SeedListByCaveGetResponseDto; +import com.example.growthookserver.api.seed.dto.response.SeedListGetResponseDto; import com.example.growthookserver.api.seed.dto.response.SeedMoveResponseDto; import java.util.List; @@ -31,7 +29,10 @@ public interface SeedService { SeedMoveResponseDto moveSeed(Long seedId, SeedMoveRequestDto seedMoveRequestDto); //* 보관함별 씨앗 리스트 조회 - List getSeedListByCave(Long caveId); + List getSeedListByCave(Long caveId); + + //* 씨앗 전체 리스트 조회 + List getSeedList(); //* 씨앗 알림 조회 SeedAlarmGetResponseDto getSeedAlarm(Long memberId); diff --git a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java index ca305e2..3be4ddd 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java +++ b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java @@ -35,6 +35,7 @@ public enum SuccessStatus { GET_SEED_DETAIL(HttpStatus.OK, "씨앗 상세 정보 조회 성공"), MOVE_SEED_SUCCESS(HttpStatus.OK, "씨앗 이동 성공"), GET_SEED_LIST_BY_CAVE(HttpStatus.OK, "보관함별로 씨앗 리스트 조회 성공"), + GET_SEED_LIST(HttpStatus.OK, "전체 씨앗 리스트 조회 성공" ), GET_SEED_ALARM(HttpStatus.OK,"씨앗 알람 조회 성공"), /**