Skip to content

Commit

Permalink
feat: 서비스 피드백 조회 api
Browse files Browse the repository at this point in the history
  • Loading branch information
alsdl0629 committed May 26, 2024
1 parent 140dd09 commit 9e4fe61
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.onboard.server.domain.feedback.controller

import com.onboard.server.domain.feedback.controller.dto.GetAllFeedbacksResponse
import com.onboard.server.domain.feedback.controller.dto.WriteFeedbackRequest
import com.onboard.server.domain.feedback.service.FeedbackService
import com.onboard.server.domain.team.domain.Subject
import com.onboard.server.global.common.ApiResponse
import jakarta.validation.Valid
import jakarta.validation.constraints.NotNull
import org.springframework.validation.annotation.Validated
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
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@Validated
@RequestMapping("/api/v1/feedbacks")
@RestController
class FeedbackController(
Expand All @@ -17,4 +25,8 @@ class FeedbackController(
fun write(@RequestBody @Valid request: WriteFeedbackRequest) {
feedbackService.write(request)
}

@GetMapping("/{serviceId}")
fun getAll(subject: Subject, @PathVariable @NotNull serviceId: Long): ApiResponse<GetAllFeedbacksResponse> =
ApiResponse.ok(feedbackService.getAll(subject, serviceId))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.onboard.server.domain.feedback.controller.dto

data class FeedbackElement(
val path: String,
val title: String,
val content: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.onboard.server.domain.feedback.controller.dto

import com.onboard.server.domain.feedback.domain.Feedback

data class GetAllFeedbacksResponse(
val feedbacks: List<FeedbackElement>,
) {
companion object {
fun from(feedbacks: List<Feedback>) = GetAllFeedbacksResponse(
feedbacks.map {
FeedbackElement(
path = it.path,
title = it.title,
content = it.content,
)
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SecurityConfig(

// feedback
.requestMatchers(POST, "api/v1/feedbacks").permitAll()
.requestMatchers(GET, "api/v1/feedbacks/{serviceId}").authenticated()

.anyRequest().denyAll()
}
Expand Down

0 comments on commit 9e4fe61

Please sign in to comment.