-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/#33 문항세트 단일 조회, 검색 구현 및 변경사항 반영 #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f603bfb
[chore/#33] local env 파일 추가
seokbeom00 d520a95
[feat/#33] 문항세트 조회 api 추가
seokbeom00 ba49c98
[fix/#33] 문항세트 title로 필드명 변경
seokbeom00 2cb9c73
[feat/#33] 문항세트 검색 api 추가
seokbeom00 7cfcf71
[fix/#33] 문항세트 검색시 태그명 필드 삭제
seokbeom00 685cd61
[fix/#33] 문항세트 순서 api swagger에서 제거
seokbeom00 3d6f968
[fix/#33] 문항세트 변경사항 반영
seokbeom00 060d5b2
[fix/#33] 테스트 데이터 수정
seokbeom00 f2a110f
[fix/#33] 리뷰 사항 반영
seokbeom00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ build/ | |
| !**/src/main/**/build/ | ||
| !**/src/test/**/build/ | ||
| .env | ||
| local.env | ||
|
|
||
| ### STS ### | ||
| .apt_generated | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ava/com/moplus/moplus_server/domain/problemset/controller/ProblemSetSearchController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.moplus.moplus_server.domain.problemset.controller; | ||
|
|
||
|
|
||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemSetSearchGetResponse; | ||
| import com.moplus.moplus_server.domain.problemset.repository.ProblemSetSearchRepositoryCustom; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| 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.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/problemSet") | ||
| @RequiredArgsConstructor | ||
| public class ProblemSetSearchController { | ||
|
|
||
| private final ProblemSetSearchRepositoryCustom problemSetSearchRepository; | ||
|
|
||
| @GetMapping("/search") | ||
| @Operation( | ||
| summary = "문항세트 검색", | ||
| description = "문항세트 타이틀, 문항세트 내 포함된 개념태그, 문항세트 내 포함된 문항 타이틀로 검색합니다." | ||
| ) | ||
| public ResponseEntity<List<ProblemSetSearchGetResponse>> search( | ||
| @RequestParam(value = "problemSetTitle", required = false) String problemSetTitle, | ||
| @RequestParam(value = "problemTitle", required = false) String problemTitle, | ||
| @RequestParam(value = "conceptTagNames", required = false) List<String> conceptTagNames | ||
| ) { | ||
| List<ProblemSetSearchGetResponse> problemSets = problemSetSearchRepository.search(problemSetTitle, problemTitle, conceptTagNames); | ||
| return ResponseEntity.ok(problemSets); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/moplus/moplus_server/domain/problemset/domain/Title.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.moplus.moplus_server.domain.problemset.domain; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Embeddable; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Embeddable | ||
| @NoArgsConstructor | ||
| public class Title { | ||
|
|
||
| private static final String DEFAULT_TITLE = "제목 없음"; | ||
|
|
||
| @Column(name = "title", nullable = false) | ||
| private String value; | ||
|
|
||
| public Title(String title) { | ||
| this.value = verifyTitle(title); | ||
| } | ||
|
|
||
| private static String verifyTitle(String title) { | ||
| return (title == null || title.trim().isEmpty()) ? DEFAULT_TITLE : title; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...n/java/com/moplus/moplus_server/domain/problemset/dto/response/ProblemSetGetResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.moplus.moplus_server.domain.problemset.dto.response; | ||
|
|
||
| import com.moplus.moplus_server.domain.problemset.domain.ProblemSet; | ||
| import com.moplus.moplus_server.domain.problemset.domain.ProblemSetConfirmStatus; | ||
| import java.util.List; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record ProblemSetGetResponse( | ||
| Long id, | ||
| String title, | ||
| ProblemSetConfirmStatus confirmStatus, | ||
| List<ProblemSummaryResponse> problemSummaries | ||
| ) { | ||
| public static ProblemSetGetResponse of(ProblemSet problemSet, List<ProblemSummaryResponse> problemSummaries) { | ||
|
|
||
| return ProblemSetGetResponse.builder() | ||
| .id(problemSet.getId()) | ||
| .title(problemSet.getTitle().getValue()) | ||
| .confirmStatus(problemSet.getConfirmStatus()) | ||
| .problemSummaries(problemSummaries) | ||
| .build(); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
.../com/moplus/moplus_server/domain/problemset/dto/response/ProblemSetSearchGetResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.moplus.moplus_server.domain.problemset.dto.response; | ||
|
|
||
| import java.util.List; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| public class ProblemSetSearchGetResponse { | ||
| private String problemSetTitle; | ||
| private List<ProblemThumbnailResponse> problemThumbnailResponses; | ||
|
|
||
| public ProblemSetSearchGetResponse( | ||
| String problemSetTitle, List<ProblemThumbnailResponse> problemThumbnailResponses | ||
| ) { | ||
| this.problemSetTitle = problemSetTitle; | ||
| this.problemThumbnailResponses = problemThumbnailResponses; | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
.../java/com/moplus/moplus_server/domain/problemset/dto/response/ProblemSummaryResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.moplus.moplus_server.domain.problemset.dto.response; | ||
|
|
||
| import com.moplus.moplus_server.domain.problem.domain.problem.Problem; | ||
| import java.util.List; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record ProblemSummaryResponse( | ||
| String problemId, | ||
| int number, | ||
| String practiceTestName, | ||
| String comment, | ||
| String mainProblemImageUrl, | ||
| List<String> tagNames | ||
| ) { | ||
| public static ProblemSummaryResponse of(Problem problem, String practiceTestName, List<String> tagNames) { | ||
|
|
||
| return ProblemSummaryResponse.builder() | ||
| .problemId(problem.getId().toString()) | ||
| .number(problem.getNumber()) | ||
| .comment(problem.getComment()) | ||
| .mainProblemImageUrl(problem.getMainProblemImageUrl()) | ||
| .practiceTestName(practiceTestName) | ||
| .tagNames(tagNames) | ||
| .build(); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...ava/com/moplus/moplus_server/domain/problemset/dto/response/ProblemThumbnailResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.moplus.moplus_server.domain.problemset.dto.response; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| public class ProblemThumbnailResponse { | ||
| private String mainProblemImageUrl; | ||
|
|
||
| public ProblemThumbnailResponse(String mainProblemImageUrl) { | ||
| this.mainProblemImageUrl = mainProblemImageUrl; | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
...m/moplus/moplus_server/domain/problemset/repository/ProblemSetSearchRepositoryCustom.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package com.moplus.moplus_server.domain.problemset.repository; | ||
|
|
||
| import static com.moplus.moplus_server.domain.concept.domain.QConceptTag.conceptTag; | ||
| import static com.moplus.moplus_server.domain.problem.domain.problem.QProblem.problem; | ||
| import static com.moplus.moplus_server.domain.problemset.domain.QProblemSet.problemSet; | ||
|
|
||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemSetSearchGetResponse; | ||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemThumbnailResponse; | ||
| import com.querydsl.core.group.GroupBy; | ||
| import com.querydsl.core.types.Projections; | ||
| import com.querydsl.core.types.dsl.BooleanExpression; | ||
| import com.querydsl.jpa.impl.JPAQueryFactory; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class ProblemSetSearchRepositoryCustom { | ||
|
|
||
| private final JPAQueryFactory queryFactory; | ||
|
|
||
| public List<ProblemSetSearchGetResponse> search(String problemSetTitle, String problemTitle, List<String> conceptTagNames) { | ||
| return queryFactory | ||
| .from(problemSet) | ||
| .leftJoin(problem).on(problem.id.in(problemSet.problemIds)) // 문제 세트 내 포함된 문항과 조인 | ||
| .leftJoin(conceptTag).on(conceptTag.id.in(problem.conceptTagIds)) // 문제의 개념 태그 조인 | ||
| .where( | ||
| containsProblemSetTitle(problemSetTitle), | ||
| containsProblemTitle(problemTitle), | ||
| containsConceptTagNames(conceptTagNames) | ||
| ) | ||
| .distinct() | ||
| .transform(GroupBy.groupBy(problemSet.id).list( | ||
| Projections.constructor(ProblemSetSearchGetResponse.class, | ||
| problemSet.title.value, | ||
| GroupBy.list( | ||
| Projections.constructor(ProblemThumbnailResponse.class, | ||
| problem.mainProblemImageUrl | ||
| ) | ||
| ) | ||
| ) | ||
| )); | ||
| } | ||
|
|
||
| private BooleanExpression containsProblemSetTitle(String problemSetTitle) { | ||
| return (problemSetTitle == null || problemSetTitle.isEmpty()) ? null : problemSet.title.value.containsIgnoreCase(problemSetTitle); | ||
| } | ||
|
|
||
| private BooleanExpression containsProblemTitle(String problemTitle) { | ||
| return (problemTitle == null || problemTitle.isEmpty()) ? null : problem.comment.containsIgnoreCase(problemTitle); | ||
| } | ||
|
|
||
| private BooleanExpression containsConceptTagNames(List<String> conceptTagNames) { | ||
| return (conceptTagNames == null || conceptTagNames.isEmpty()) ? null : conceptTag.name.in(conceptTagNames); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/moplus/moplus_server/domain/problemset/service/ProblemSetGetService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.moplus.moplus_server.domain.problemset.service; | ||
|
|
||
| import com.moplus.moplus_server.domain.concept.domain.ConceptTag; | ||
| import com.moplus.moplus_server.domain.concept.repository.ConceptTagRepository; | ||
| import com.moplus.moplus_server.domain.problem.domain.practiceTest.PracticeTestTag; | ||
| import com.moplus.moplus_server.domain.problem.domain.problem.Problem; | ||
| import com.moplus.moplus_server.domain.problem.domain.problem.ProblemId; | ||
| import com.moplus.moplus_server.domain.problem.repository.PracticeTestTagRepository; | ||
| import com.moplus.moplus_server.domain.problem.repository.ProblemRepository; | ||
| import com.moplus.moplus_server.domain.problemset.domain.ProblemSet; | ||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemSetGetResponse; | ||
| import com.moplus.moplus_server.domain.problemset.dto.response.ProblemSummaryResponse; | ||
| import com.moplus.moplus_server.domain.problemset.repository.ProblemSetRepository; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class ProblemSetGetService { | ||
|
|
||
| private final ProblemSetRepository problemSetRepository; | ||
| private final ProblemRepository problemRepository; | ||
| private final PracticeTestTagRepository practiceTestTagRepository; | ||
| private final ConceptTagRepository conceptTagRepository; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public ProblemSetGetResponse getProblemSet(Long problemSetId) { | ||
|
|
||
| ProblemSet problemSet = problemSetRepository.findByIdElseThrow(problemSetId); | ||
|
|
||
| List<ProblemSummaryResponse> problemSummaries = new ArrayList<>(); | ||
| for (ProblemId problemId : problemSet.getProblemIds()) { | ||
| Problem problem = problemRepository.findByIdElseThrow(problemId); | ||
| PracticeTestTag practiceTestTag = practiceTestTagRepository.findByIdElseThrow(problem.getPracticeTestId()); | ||
| List<String> tagNames = conceptTagRepository.findAllByIdsElseThrow(problem.getConceptTagIds()) | ||
| .stream() | ||
| .map(ConceptTag::getName) | ||
| .toList(); | ||
| problemSummaries.add(ProblemSummaryResponse.of(problem, practiceTestTag.getName(), tagNames)); | ||
| } | ||
| return ProblemSetGetResponse.of(problemSet, problemSummaries); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문항 변동 사항 반영 전이라 아직 problem에 메모가 없는데 이후에 수정이 나을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment가 memo로 바뀌는걸로 알고 있습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문항 title외에도 문항memo 필터링 요소가 추가되는 것일까요?
만약 그렇다면, 추가된 이후에 수정하겠습니다!