Skip to content

Commit

Permalink
fix: 코드 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
JINU-CHANG committed Jul 25, 2024
1 parent 6086eda commit f44b0f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -43,10 +44,14 @@ public String getDescription() {

public Badge getBadge() { return badge; }

public Set<Integer> getQuestionIds() {
return questionIds;
}

public static List<Badge> getBadges(List<ChecklistQuestion> questions) {
return Arrays.stream(values())
.filter(category -> {
List<Integer> questionIds = category.questionIds;
Set<Integer> questionIds = category.questionIds;
List<ChecklistQuestion> categoryQuestions = questions.stream()
.filter(checklistQuestion -> questionIds.contains(checklistQuestion.getQuestionId()))
.toList();
Expand All @@ -62,8 +67,5 @@ public static List<Badge> getBadges(List<ChecklistQuestion> questions) {
})
.map(Category::getBadge)
.toList();

public Set<Integer> getQuestionIds() {
return questionIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public ResponseEntity<Void> createChecklist(@Valid @RequestBody ChecklistCreateR
@GetMapping("/checklists")
public ResponseEntity<UserChecklistsPreviewResponse> readUserChecklistsPreview() {
return ResponseEntity.ok(checklistService.readUserChecklistsPreview());
}

@GetMapping("/checklists/questions")
public ResponseEntity<ChecklistQuestionsResponse> readChecklistQuestions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Checklist extends BaseEntity {

private String realEstate;

@OneToMany(mappedBy = "checklist_question")
@OneToMany(mappedBy = "checklist")
private List<ChecklistQuestion> questions;

public Checklist(User user, Room room, Integer deposit, Integer rent, Integer contractTerm, String realEstate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -145,12 +145,14 @@ private List<BadgeResponse> createBadges(List<ChecklistQuestion> questions) {
return Category.getBadges(questions).stream()
.map(BadgeResponse::from)
.toList();

public ChecklistQuestionsResponse readChecklistQuestions() {
}

public ChecklistQuestionsResponse readChecklistQuestions () {
List<CategoryQuestionsResponse> 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);
Expand Down

0 comments on commit f44b0f4

Please sign in to comment.