Skip to content

Commit

Permalink
feat : plan 상세 조회 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Ready-Bridge committed Sep 28, 2024
1 parent 465a2ba commit 1c3571d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.cokothon.domain.plan.controller;

import com.github.cokothon.domain.plan.dto.response.GetPlanResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -32,6 +33,13 @@ public ApiResponse<GetPlansResponse> getPlans() {
return ApiResponse.ok(planService.getPlans());
}

@GetMapping("/{planId}")
public ApiResponse<GetPlanResponse> getPlan(@PathVariable("planId") String planId) {


return ApiResponse.ok(planService.getPlan(planId));
}

@GetMapping("/best")
public ApiResponse<GetPlansResponse> getBestPlans() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.github.cokothon.domain.plan.dto.response;

import com.github.cokothon.domain.plan.schema.Plan;
import lombok.Builder;

@Builder
public record GetPlanResponse(
Plan plan
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import com.github.cokothon.domain.plan.dto.response.GetPlanResponse;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
Expand Down Expand Up @@ -33,6 +34,16 @@ public GetPlansResponse getPlans() {
.build();
}

public GetPlanResponse getPlan(String planId) {

Plan plan = planRepository.findById(planId)
.orElseThrow(PlanNotFoundException::new);

return GetPlanResponse.builder()
.plan(plan)
.build();
}

public GetPlansResponse getBestPlans() {

Query query = new Query()
Expand Down

0 comments on commit 1c3571d

Please sign in to comment.