From dd676e0878b59ab49b77fdd43b1d082dec1c8c92 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Fri, 5 Jan 2024 05:57:47 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[FEAT]=20#54=20=EC=94=A8=EC=95=97=20?= =?UTF-8?q?=EC=9E=A0=EA=B8=88=20=ED=95=B4=EC=A0=9C=20API=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/seed/controller/SeedController.java | 8 ++++++++ .../com/example/growthookserver/api/seed/domain/Seed.java | 2 ++ .../api/seed/service/Impl/SeedServiceImpl.java | 7 +++++++ .../growthookserver/api/seed/service/SeedService.java | 2 ++ .../growthookserver/common/response/SuccessStatus.java | 1 + 5 files changed, 20 insertions(+) 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 00f9c58..0c4b4dc 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 @@ -94,4 +94,12 @@ public ApiResponse getSeedAlarm(@PathVariable Long memb return ApiResponse.success(SuccessStatus.GET_SEED_ALARM, seedService.getSeedAlarm(memberId)); } + @PatchMapping("seed/{seedId}/lock/status") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "unlockSeed", description = "인사이트 잠금을 해제하는 API입니다.") + public ApiResponse unlockSeed(@PathVariable Long seedId) { + seedService.unlockSeed(seedId); + return ApiResponse.success(SuccessStatus.UNLOCK_SEED.getStatusCode(), SuccessStatus.UNLOCK_SEED.getMessage()); + } + } 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 5082f8a..b572498 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 @@ -74,4 +74,6 @@ public void changeCave(Cave newCave) { } public void toggleScrapStatus() { this.isScraped = !this.isScraped; } + + public void unlockSeed() { this.isLocked = false; } } 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 0e68bf2..2c47a74 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 @@ -118,6 +118,13 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { return SeedAlarmGetResponseDto.of(seedCount); } + @Override + @Transactional + public void unlockSeed(Long seedId) { + Seed seed = seedRepository.findSeedByIdOrThrow(seedId); + seed.unlockSeed(); + } + @Override @Transactional public void toggleSeedScrapStatus(Long seedId) { 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 563a51e..d3458a8 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 @@ -40,4 +40,6 @@ public interface SeedService { //* 씨앗 알림 조회 SeedAlarmGetResponseDto getSeedAlarm(Long memberId); + //* 씨앗 잠금 해제 + void unlockSeed(Long seedId); } 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 20c7627..e5e154e 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 @@ -37,6 +37,7 @@ public enum SuccessStatus { GET_SEED_LIST(HttpStatus.OK, "전체 씨앗 리스트 조회 성공" ), TOGGLE_SEED_SCRAP_STATUS(HttpStatus.OK, "씨앗 스크랩 여부 토글 전환 성공"), GET_SEED_ALARM(HttpStatus.OK,"씨앗 알람 조회 성공"), + UNLOCK_SEED(HttpStatus.OK, "씨앗 잠금 해제 성공"), /** * actionplan From 59e0a8070397f77aa90d50ba4d805a827ab1cf00 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Fri, 5 Jan 2024 07:14:03 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[ADD]=20=EC=94=A8=EC=95=97=20=EC=9E=A0?= =?UTF-8?q?=EA=B8=88=20=ED=95=B4=EC=A0=9C=20=EC=8B=9C,=20=EC=88=98?= =?UTF-8?q?=ED=99=95=ED=95=9C=20=EC=91=A5=EC=9D=84=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/growthookserver/api/member/domain/Member.java | 5 +++++ .../api/seed/service/Impl/SeedServiceImpl.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java index 7d567eb..3ce450c 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java @@ -56,4 +56,9 @@ public Member(String nickname, String email, SocialPlatform socialPlatform, Bool public void incrementGatheredSsuk() { this.gatheredSsuk = (this.gatheredSsuk == null ? 0 : this.gatheredSsuk) + 1; } + + public void useSsuck() { + this.gatheredSsuk--; + this.usedSsuk++; + } } 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 2c47a74..a5b8a2e 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 @@ -4,6 +4,8 @@ import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository; import com.example.growthookserver.api.cave.domain.Cave; import com.example.growthookserver.api.cave.repository.CaveRepository; +import com.example.growthookserver.api.member.domain.Member; +import com.example.growthookserver.api.member.repository.MemberRepository; import com.example.growthookserver.api.seed.domain.Seed; import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto; @@ -35,6 +37,7 @@ public class SeedServiceImpl implements SeedService { private final CaveRepository caveRepository; private final SeedRepository seedRepository; private final ActionPlanRepository actionPlanRepository; + private final MemberRepository memberRepository; @Override @Transactional @@ -123,6 +126,10 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { public void unlockSeed(Long seedId) { Seed seed = seedRepository.findSeedByIdOrThrow(seedId); seed.unlockSeed(); + + Long memberId = seed.getMemberId(); + Member member = memberRepository.findMemberByIdOrThrow(memberId); + member.useSsuck(); } @Override From ca2ed3be3053b7644b7a3368750b6653151658fd Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Mon, 8 Jan 2024 02:50:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[FEAT]=20=EC=95=A1=EC=85=98=ED=94=8C?= =?UTF-8?q?=EB=9E=9C=20=EB=B3=84=20=EB=A6=AC=EB=B7=B0=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=20API=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActionPlanController.java | 12 +++---- .../review/controller/ReviewController.java | 34 +++++++++++++++++++ .../dto/request/ReviewCreateRequestDto.java | 17 ++++++++++ .../review/repository/ReviewRepository.java | 8 +++++ .../api/review/service/ReviewService.java | 10 ++++++ .../api/review/service/ReviewServiceImpl.java | 32 +++++++++++++++++ .../common/response/SuccessStatus.java | 5 +++ 7 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/review/dto/request/ReviewCreateRequestDto.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java index ddc1694..b24130f 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java @@ -23,7 +23,7 @@ public class ActionPlanController { private final ActionPlanService actionPlanService; - @PostMapping("seed/{seedId}/actionPlan") + @PostMapping("seed/{seedId}/actionplan") @ResponseStatus(HttpStatus.CREATED) @Operation(summary = "ActionPlanPost",description = "액션 플랜 생성 API입니다.") public ApiResponse createActionPlan(@PathVariable("seedId")Long seedId, @Valid @RequestBody ActionPlanCreateRequestDto actionPlanCreateRequestDto) { @@ -31,14 +31,14 @@ public ApiResponse createActionPlan(@PathVariable("seedId")Long seedId, @Valid @ return ApiResponse.success(SuccessStatus.POST_ACTIONPLAN_SUCCESS.getStatusCode(), SuccessStatus.POST_ACTIONPLAN_SUCCESS.getMessage()); } - @GetMapping("seed/{seedId}/actionPlan") + @GetMapping("seed/{seedId}/actionplan") @ResponseStatus(HttpStatus.OK) @Operation(summary = "ActionPlanGet", description = "씨앗 별 액션 플랜 조회 API입니다.") public ApiResponse getActionPlan(@PathVariable Long seedId) { return ApiResponse.success(SuccessStatus.GET_SEED_ACTIONPLAN_SUCCESS, actionPlanService.getActionPlan(seedId)); } - @PatchMapping("actionPlan/{actionPlanId}") + @PatchMapping("actionplan/{actionPlanId}") @ResponseStatus(HttpStatus.OK) @Operation(summary = "ActionPlanPatch", description = "액션 플랜 내용을 수정하는 API입니다.") public ApiResponse updateActionPlan(@PathVariable Long actionPlanId, @Valid @RequestBody ActionPlanUpdateRequestDto actionPlanUpdateRequestDto) { @@ -46,7 +46,7 @@ public ApiResponse updateActionPlan(@PathVariable Long actionPlanId, @Valid @Req return ApiResponse.success(SuccessStatus.PATCH_ACTIONPLAN_SUCCESS.getStatusCode(), SuccessStatus.PATCH_ACTIONPLAN_SUCCESS.getMessage()); } - @DeleteMapping("actionPlan/{actionPlanId}") + @DeleteMapping("actionplan/{actionPlanId}") @ResponseStatus(HttpStatus.OK) @Operation(summary = "ActionPlanDelete", description = "액션 플랜을 삭제하는 API입니다.") public ApiResponse deleteActionPlan(@PathVariable Long actionPlanId) { @@ -54,7 +54,7 @@ public ApiResponse deleteActionPlan(@PathVariable Long actionPlanId) { return ApiResponse.success(SuccessStatus.DELETE_ACTIONPLAN_SUCCESS.getStatusCode(), SuccessStatus.DELETE_ACTIONPLAN_SUCCESS.getMessage()); } - @PatchMapping("actionPlan/{actionPlanId}/completion") + @PatchMapping("actionplan/{actionPlanId}/completion") @ResponseStatus(HttpStatus.OK) @Operation(summary = "ActionPlanComplete", description = "액션 플랜을 완료하는 API입니다.") public ApiResponse completeActionPlan(@PathVariable Long actionPlanId) { @@ -62,7 +62,7 @@ public ApiResponse completeActionPlan(@PathVariable Long actionPlanId) { return ApiResponse.success(SuccessStatus.COMPLETE_ACTIONPLAN_SUCCESS.getStatusCode(),SuccessStatus.COMPLETE_ACTIONPLAN_SUCCESS.getMessage()); } - @GetMapping("member/{memberId}/actionPlan/percent") + @GetMapping("member/{memberId}/actionplan/percent") @ResponseStatus(HttpStatus.OK) @Operation(summary = "ActionPlanPercent", description = "완료한 액션 플랜 퍼센트를 구하는 API입니다.") public ApiResponse getActionPlanPercent(@PathVariable Long memberId) { diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java new file mode 100644 index 0000000..52a9dcf --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java @@ -0,0 +1,34 @@ +package com.example.growthookserver.api.review.controller; + +import com.example.growthookserver.api.review.dto.request.ReviewCreateRequestDto; +import com.example.growthookserver.api.review.service.ReviewService; +import com.example.growthookserver.common.response.ApiResponse; +import com.example.growthookserver.common.response.SuccessStatus; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("api/v1") +@Tag(name = "Review - 리뷰 관련 API", description = "Review API Document") +public class ReviewController { + + private final ReviewService reviewService; + @PostMapping("actionplan/{actionPlanId}/review") + @ResponseStatus(HttpStatus.CREATED) + @Operation(summary = "ReviewPost", description = "리뷰 생성 API입니다.") + public ApiResponse createReview(@PathVariable("actionPlanId") Long actionPlanId, @Valid @RequestBody ReviewCreateRequestDto reviewCreateRequestDto) { + reviewService.createReview(actionPlanId, reviewCreateRequestDto); + return ApiResponse.success( + SuccessStatus.POST_REVIEW_SUCCESS.getStatusCode(), SuccessStatus.POST_REVIEW_SUCCESS.getMessage()); + } +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/dto/request/ReviewCreateRequestDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/dto/request/ReviewCreateRequestDto.java new file mode 100644 index 0000000..ba4123d --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/dto/request/ReviewCreateRequestDto.java @@ -0,0 +1,17 @@ +package com.example.growthookserver.api.review.dto.request; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class ReviewCreateRequestDto { + @NotBlank + @Size(max = 300) + private String content; +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java new file mode 100644 index 0000000..fb569e5 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java @@ -0,0 +1,8 @@ +package com.example.growthookserver.api.review.repository; + +import com.example.growthookserver.api.review.domain.Review; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReviewRepository extends JpaRepository { + +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java new file mode 100644 index 0000000..9744213 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java @@ -0,0 +1,10 @@ +package com.example.growthookserver.api.review.service; + +import com.example.growthookserver.api.review.dto.request.ReviewCreateRequestDto; + +public interface ReviewService{ + + //* 액션 플랜별 리뷰 작성 + void createReview(Long actionPlanId, ReviewCreateRequestDto reviewCreateRequestDto); + +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java new file mode 100644 index 0000000..0bda40d --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java @@ -0,0 +1,32 @@ +package com.example.growthookserver.api.review.service; + +import com.example.growthookserver.api.actionplan.domain.ActionPlan; +import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository; +import com.example.growthookserver.api.review.domain.Review; +import com.example.growthookserver.api.review.dto.request.ReviewCreateRequestDto; +import com.example.growthookserver.api.review.repository.ReviewRepository; +import com.example.growthookserver.api.seed.domain.Seed; +import com.example.growthookserver.api.seed.repository.SeedRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class ReviewServiceImpl implements ReviewService { + + private final ReviewRepository reviewRepository; + private final ActionPlanRepository actionPlanRepository; + + @Override + @Transactional + public void createReview(Long actionPlanId, ReviewCreateRequestDto reviewCreateRequestDto) { + ActionPlan actionPlan = actionPlanRepository.findActionPlanByIdOrThrow(actionPlanId); + Review review = Review.builder() + .content(reviewCreateRequestDto.getContent()) + .actionPlan(actionPlan) + .build(); + reviewRepository.save(review); + } +} 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 e5e154e..ed1aa24 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 @@ -50,6 +50,11 @@ public enum SuccessStatus { GET_FINISHED_ACTIONPLAN_PERCENT(HttpStatus.OK, "완료한 액션 플랜 퍼센트 조회 성공"), GET_DOING_ACTIONPLAN_SUCCESS(HttpStatus.OK, "진행 중인 액션 플랜 리스트 조회 성공"), GET_FINISHED_ACTIONPLAN_SUCCESS(HttpStatus.OK,"완료한 액션 플랜 리스트 조회 성공"), + + /** + * review + */ + POST_REVIEW_SUCCESS(HttpStatus.CREATED, "리뷰 생성 성공"), ; private final HttpStatus httpStatus; From 8c01663c87a29b760f195d6c833886e1cdd91d21 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Mon, 8 Jan 2024 03:24:59 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[FEAT]=20=EB=A6=AC=EB=B7=B0=20=EB=82=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20API=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../review/controller/ReviewController.java | 9 +++++++++ .../response/ReviewDetailGetResponseDto.java | 16 ++++++++++++++++ .../review/repository/ReviewRepository.java | 11 +++++++++++ .../api/review/service/ReviewService.java | 3 +++ .../api/review/service/ReviewServiceImpl.java | 18 ++++++++++++++++-- .../common/response/ErrorStatus.java | 1 + .../common/response/SuccessStatus.java | 1 + 7 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/review/dto/response/ReviewDetailGetResponseDto.java diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java index 52a9dcf..8425446 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java @@ -1,6 +1,7 @@ package com.example.growthookserver.api.review.controller; import com.example.growthookserver.api.review.dto.request.ReviewCreateRequestDto; +import com.example.growthookserver.api.review.dto.response.ReviewDetailGetResponseDto; import com.example.growthookserver.api.review.service.ReviewService; import com.example.growthookserver.common.response.ApiResponse; import com.example.growthookserver.common.response.SuccessStatus; @@ -9,6 +10,7 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -31,4 +33,11 @@ public ApiResponse createReview(@PathVariable("actionPlanId") Long actionPlanId, return ApiResponse.success( SuccessStatus.POST_REVIEW_SUCCESS.getStatusCode(), SuccessStatus.POST_REVIEW_SUCCESS.getMessage()); } + + @GetMapping("actionplan/{actionPlanId}/review") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "ReveiwGet", description = "리뷰 상세 조회 API입니다.") + public ApiResponse getReviewDetail(@PathVariable("actionPlanId") Long actionPlanId) { + return ApiResponse.success(SuccessStatus.GET_REVIEW_DETAIL, reviewService.getReviewDetail(actionPlanId)); + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/dto/response/ReviewDetailGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/dto/response/ReviewDetailGetResponseDto.java new file mode 100644 index 0000000..56704ff --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/dto/response/ReviewDetailGetResponseDto.java @@ -0,0 +1,16 @@ +package com.example.growthookserver.api.review.dto.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(staticName = "of") +public class ReviewDetailGetResponseDto { + private String actionPlan; + private Boolean isScraped; + private String content; + private String reviewDate; +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java index fb569e5..704761f 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java @@ -1,8 +1,19 @@ package com.example.growthookserver.api.review.repository; +import com.example.growthookserver.api.cave.domain.Cave; import com.example.growthookserver.api.review.domain.Review; +import com.example.growthookserver.common.exception.NotFoundException; +import com.example.growthookserver.common.response.ErrorStatus; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface ReviewRepository extends JpaRepository { + Optional findReviewByActionPlanId(Long actionPlanId); + + default Review findReviewByActionPlanIdOrThrow(Long actionPlanId) { + return findReviewByActionPlanId(actionPlanId) + .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_REVIEW.getMessage())); + } + } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java index 9744213..3afa37b 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java @@ -1,10 +1,13 @@ package com.example.growthookserver.api.review.service; import com.example.growthookserver.api.review.dto.request.ReviewCreateRequestDto; +import com.example.growthookserver.api.review.dto.response.ReviewDetailGetResponseDto; public interface ReviewService{ //* 액션 플랜별 리뷰 작성 void createReview(Long actionPlanId, ReviewCreateRequestDto reviewCreateRequestDto); + //* 리뷰 내용 상세 조회 + ReviewDetailGetResponseDto getReviewDetail(Long actionPlanId); } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java index 0bda40d..45f1113 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java @@ -4,9 +4,10 @@ import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository; import com.example.growthookserver.api.review.domain.Review; import com.example.growthookserver.api.review.dto.request.ReviewCreateRequestDto; +import com.example.growthookserver.api.review.dto.response.ReviewDetailGetResponseDto; import com.example.growthookserver.api.review.repository.ReviewRepository; -import com.example.growthookserver.api.seed.domain.Seed; -import com.example.growthookserver.api.seed.repository.SeedRepository; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,4 +30,17 @@ public void createReview(Long actionPlanId, ReviewCreateRequestDto reviewCreateR .build(); reviewRepository.save(review); } + + @Override + public ReviewDetailGetResponseDto getReviewDetail(Long actionPlanId) { + Review review = reviewRepository.findReviewByActionPlanIdOrThrow(actionPlanId); + ActionPlan actionPlan = review.getActionPlan(); + return ReviewDetailGetResponseDto.of(actionPlan.getContent(), actionPlan.getIsScraped(), + review.getContent(), formatReviewDate(review.getCreatedAt())); + } + + private String formatReviewDate(LocalDateTime reviewDate) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); + return reviewDate.format(formatter); + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java b/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java index 835502e..a63ca96 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java +++ b/growthookServer/src/main/java/com/example/growthookserver/common/response/ErrorStatus.java @@ -34,6 +34,7 @@ public enum ErrorStatus { NOT_FOUND_CAVE("해당하는 동굴이 없습니다."), NOT_FOUND_SEED("해당하는 씨앗이 없습니다."), NOT_FOUND_ACTIONPLAN("해당하는 액션 플랜이 없습니다."), + NOT_FOUND_REVIEW("해당하는 액션플랜에 작성된 리뷰가 없습니다."), /** * 500 SERVER_ERROR 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 ed1aa24..05842d3 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 @@ -55,6 +55,7 @@ public enum SuccessStatus { * review */ POST_REVIEW_SUCCESS(HttpStatus.CREATED, "리뷰 생성 성공"), + GET_REVIEW_DETAIL(HttpStatus.OK, "리뷰 내용 상세 조회 성공"), ; private final HttpStatus httpStatus; From b78f11b5a54da90f8d1b09930840009b8acbc422 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Mon, 8 Jan 2024 03:57:05 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[FEAT]=20=EB=A9=A4=EB=B2=84=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?API=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 31 +++++++++++++++++++ .../response/MemberDetailGetResponseDto.java | 14 +++++++++ .../api/member/service/MemberService.java | 9 ++++++ .../api/member/service/MemberServiceImpl.java | 22 +++++++++++++ .../review/controller/ReviewController.java | 2 +- .../common/response/SuccessStatus.java | 5 +++ 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java create mode 100644 growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java new file mode 100644 index 0000000..0cd6ec8 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/controller/MemberController.java @@ -0,0 +1,31 @@ +package com.example.growthookserver.api.member.controller; + +import com.example.growthookserver.api.member.dto.response.MemberDetailGetResponseDto; +import com.example.growthookserver.api.member.service.MemberService; +import com.example.growthookserver.common.response.ApiResponse; +import com.example.growthookserver.common.response.SuccessStatus; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("api/v1") +@Tag(name = "Member - 유저 관련 API", description = "Member API Document") +public class MemberController { + + private final MemberService memberService; + + @GetMapping("/member/{memberId}/profile") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "MemberProfileGet", description = "멤버 프로필을 조회하는 API입니다.") + public ApiResponse getMemberProfile(@PathVariable("memberId") Long memberId) { + return ApiResponse.success(SuccessStatus.GET_MEMBER_PROFILE, memberService.getMemberProfile(memberId)); + } +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java new file mode 100644 index 0000000..5e413f7 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/dto/response/MemberDetailGetResponseDto.java @@ -0,0 +1,14 @@ +package com.example.growthookserver.api.member.dto.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(staticName = "of") +public class MemberDetailGetResponseDto { + private String nickname; + private String email; +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java new file mode 100644 index 0000000..6f282c1 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberService.java @@ -0,0 +1,9 @@ +package com.example.growthookserver.api.member.service; + +import com.example.growthookserver.api.member.dto.response.MemberDetailGetResponseDto; + +public interface MemberService { + //* 멤버 프로필 정보 조회 + MemberDetailGetResponseDto getMemberProfile(Long memberId); + +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java new file mode 100644 index 0000000..a4e2c26 --- /dev/null +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/service/MemberServiceImpl.java @@ -0,0 +1,22 @@ +package com.example.growthookserver.api.member.service; + +import com.example.growthookserver.api.member.domain.Member; +import com.example.growthookserver.api.member.dto.response.MemberDetailGetResponseDto; +import com.example.growthookserver.api.member.repository.MemberRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class MemberServiceImpl implements MemberService{ + + private final MemberRepository memberRepository; + + @Override + public MemberDetailGetResponseDto getMemberProfile(Long memberId) { + Member member = memberRepository.findMemberByIdOrThrow(memberId); + return MemberDetailGetResponseDto.of(member.getNickname(), member.getEmail()); + } +} diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java index 8425446..74f34e3 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java @@ -36,7 +36,7 @@ public ApiResponse createReview(@PathVariable("actionPlanId") Long actionPlanId, @GetMapping("actionplan/{actionPlanId}/review") @ResponseStatus(HttpStatus.OK) - @Operation(summary = "ReveiwGet", description = "리뷰 상세 조회 API입니다.") + @Operation(summary = "ReviewGet", description = "리뷰 상세 조회 API입니다.") public ApiResponse getReviewDetail(@PathVariable("actionPlanId") Long actionPlanId) { return ApiResponse.success(SuccessStatus.GET_REVIEW_DETAIL, reviewService.getReviewDetail(actionPlanId)); } 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 05842d3..3e780c6 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 @@ -56,6 +56,11 @@ public enum SuccessStatus { */ POST_REVIEW_SUCCESS(HttpStatus.CREATED, "리뷰 생성 성공"), GET_REVIEW_DETAIL(HttpStatus.OK, "리뷰 내용 상세 조회 성공"), + + /** + * member + */ + GET_MEMBER_PROFILE(HttpStatus.OK, "멤버 프로필 정보 조회 성공"), ; private final HttpStatus httpStatus;