Skip to content

Commit

Permalink
Merge pull request #20 from dnd-side-project/fix/#16-create-reviewform
Browse files Browse the repository at this point in the history
[Fix] 카테고리에 해당하는 질문 반환 api 관련 오류
  • Loading branch information
heejjinkim authored Oct 13, 2024
2 parents 99a4418 + b005618 commit 31adbb0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum CategoryType {
PROBLEM_SOLVING("문제해결"),
DILIGENCE("성실성"),
IDEATION("아이데이션"),
SOCIABILITY("사회성");
CONSIDERATION("배려심");

private final String name;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
package com._119.wepro.review.dto.request;

import com._119.wepro.global.enums.CategoryType;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

public class QuestionRequest {
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class QuestionGetRequest{

private List<CategoryType> categories;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com._119.wepro.review.presentation;

import com._119.wepro.global.util.SecurityUtil;
import com._119.wepro.review.dto.request.QuestionRequest.*;
import com._119.wepro.review.dto.response.QuestionResponse.*;
import com._119.wepro.global.enums.CategoryType;
import com._119.wepro.review.dto.response.QuestionResponse.QuestionGetResponse;
import com._119.wepro.review.service.QuestionService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand All @@ -19,12 +18,11 @@
public class QuestionController {

private final QuestionService questionService;
private final SecurityUtil securityUtil;

@Operation(summary = "카테고리에 해당하는 질문들 반환 API")
@GetMapping("/categories")
public ResponseEntity<QuestionGetResponse> getQuestionsInCategories(@RequestBody @Valid QuestionGetRequest request){
securityUtil.getCurrentMemberId();
return ResponseEntity.ok(questionService.getQuestionsInCategories(request));
public ResponseEntity<QuestionGetResponse> getQuestionsInCategories(
@RequestParam List<CategoryType> categoryTypes) {
return ResponseEntity.ok(questionService.getQuestionsInCategories(categoryTypes));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import com._119.wepro.global.exception.errorcode.ReviewErrorCode;
import com._119.wepro.review.domain.Question;
import com._119.wepro.review.domain.repository.QuestionRepository;
import com._119.wepro.review.dto.request.QuestionRequest.*;
import com._119.wepro.review.dto.response.QuestionResponse.*;
import com._119.wepro.review.dto.response.QuestionResponse.QuestionGetResponse;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -17,10 +16,9 @@ public class QuestionService {

private final QuestionRepository questionRepository;

public QuestionGetResponse getQuestionsInCategories(QuestionGetRequest request) {
List<CategoryType> categories = request.getCategories();
public QuestionGetResponse getQuestionsInCategories(List<CategoryType> categoryTypes) {

List<Question> questions = categories.stream()
List<Question> questions = categoryTypes.stream()
.flatMap(category -> questionRepository.findByCategoryType(category).stream())
.toList();
if (questions.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/default-questions.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
]
},
{
"categoryType": "SOCIABILITY",
"categoryType": "CONSIDERATION",
"questions": [
{
"question": "${username}님은 팀 내에서 다른 팀원들과 협력하는 데 얼마나 적극적이었나요?",
Expand Down

0 comments on commit 31adbb0

Please sign in to comment.