-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ver/src/main/java/com/example/growthookserver/api/review/controller/ReviewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../main/java/com/example/growthookserver/api/review/dto/request/ReviewCreateRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
8 changes: 8 additions & 0 deletions
8
...ver/src/main/java/com/example/growthookserver/api/review/repository/ReviewRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Review, Long> { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...ookServer/src/main/java/com/example/growthookserver/api/review/service/ReviewService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...erver/src/main/java/com/example/growthookserver/api/review/service/ReviewServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters