diff --git a/backend/bang-ggood/src/main/java/com/bang_ggood/category/domain/Category.java b/backend/bang-ggood/src/main/java/com/bang_ggood/category/domain/Category.java index 006e4554f..990640370 100644 --- a/backend/bang-ggood/src/main/java/com/bang_ggood/category/domain/Category.java +++ b/backend/bang-ggood/src/main/java/com/bang_ggood/category/domain/Category.java @@ -4,6 +4,7 @@ import com.bang_ggood.checklist.domain.Grade; import java.util.Arrays; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; public enum Category { @@ -43,10 +44,14 @@ public String getDescription() { public Badge getBadge() { return badge; } + public Set getQuestionIds() { + return questionIds; + } + public static List getBadges(List questions) { return Arrays.stream(values()) .filter(category -> { - List questionIds = category.questionIds; + Set questionIds = category.questionIds; List categoryQuestions = questions.stream() .filter(checklistQuestion -> questionIds.contains(checklistQuestion.getQuestionId())) .toList(); @@ -62,8 +67,5 @@ public static List getBadges(List questions) { }) .map(Category::getBadge) .toList(); - - public Set getQuestionIds() { - return questionIds; } } diff --git a/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/controller/ChecklistController.java b/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/controller/ChecklistController.java index 07ef3559c..4bfe4c61a 100644 --- a/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/controller/ChecklistController.java +++ b/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/controller/ChecklistController.java @@ -30,6 +30,7 @@ public ResponseEntity createChecklist(@Valid @RequestBody ChecklistCreateR @GetMapping("/checklists") public ResponseEntity readUserChecklistsPreview() { return ResponseEntity.ok(checklistService.readUserChecklistsPreview()); + } @GetMapping("/checklists/questions") public ResponseEntity readChecklistQuestions() { diff --git a/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/domain/Checklist.java b/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/domain/Checklist.java index 688d62afb..6188cd8c5 100644 --- a/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/domain/Checklist.java +++ b/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/domain/Checklist.java @@ -36,7 +36,7 @@ public class Checklist extends BaseEntity { private String realEstate; - @OneToMany(mappedBy = "checklist_question") + @OneToMany(mappedBy = "checklist") private List questions; public Checklist(User user, Room room, Integer deposit, Integer rent, Integer contractTerm, String realEstate) { diff --git a/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/service/ChecklistService.java b/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/service/ChecklistService.java index c1b60cc22..879fa5cec 100644 --- a/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/service/ChecklistService.java +++ b/backend/bang-ggood/src/main/java/com/bang_ggood/checklist/service/ChecklistService.java @@ -12,9 +12,9 @@ import com.bang_ggood.checklist.dto.ChecklistInfo; import com.bang_ggood.checklist.dto.ChecklistQuestionsResponse; import com.bang_ggood.checklist.dto.QuestionCreateRequest; +import com.bang_ggood.checklist.dto.QuestionResponse; import com.bang_ggood.checklist.dto.UserChecklistPreviewResponse; import com.bang_ggood.checklist.dto.UserChecklistsPreviewResponse; -import com.bang_ggood.checklist.dto.QuestionResponse; import com.bang_ggood.checklist.repository.ChecklistOptionRepository; import com.bang_ggood.checklist.repository.ChecklistQuestionRepository; import com.bang_ggood.checklist.repository.ChecklistRepository; @@ -145,12 +145,14 @@ private List createBadges(List questions) { return Category.getBadges(questions).stream() .map(BadgeResponse::from) .toList(); - - public ChecklistQuestionsResponse readChecklistQuestions() { + } + + public ChecklistQuestionsResponse readChecklistQuestions () { List categoryQuestionsResponses = new ArrayList<>(); for (Category category : Category.values()) { CategoryQuestionsResponse categoryQuestionsResponse = - new CategoryQuestionsResponse(category.getId(), category.getDescription(), readChecklistQuestion(category)); + new CategoryQuestionsResponse(category.getId(), category.getDescription(), + readChecklistQuestion(category)); categoryQuestionsResponses.add(categoryQuestionsResponse); } return new ChecklistQuestionsResponse(categoryQuestionsResponses);