File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
backend/src/main/java/wooteco/prolog/roadmap Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
package wooteco .prolog .roadmap .application ;
2
2
3
+ import static wooteco .prolog .common .exception .BadRequestCode .CURRICULUM_NOT_FOUND_EXCEPTION ;
4
+
3
5
import java .util .List ;
4
6
import java .util .Set ;
5
7
import java .util .stream .Collectors ;
6
8
import lombok .RequiredArgsConstructor ;
7
9
import org .springframework .stereotype .Service ;
8
10
import org .springframework .transaction .annotation .Transactional ;
11
+ import wooteco .prolog .common .exception .BadRequestException ;
9
12
import wooteco .prolog .roadmap .application .dto .KeywordsResponse ;
10
13
import wooteco .prolog .roadmap .domain .Curriculum ;
11
14
import wooteco .prolog .roadmap .domain .Keyword ;
@@ -26,8 +29,7 @@ public class RoadMapService {
26
29
@ Transactional (readOnly = true )
27
30
public KeywordsResponse findAllKeywords (final Long curriculumId ) {
28
31
final Curriculum curriculum = curriculumRepository .findById (curriculumId )
29
- .orElseThrow (() -> new IllegalArgumentException (
30
- "해당 커리큘럼이 존재하지 않습니다. curriculumId = " + curriculumId ));
32
+ .orElseThrow (() -> new BadRequestException (CURRICULUM_NOT_FOUND_EXCEPTION ));
31
33
32
34
final Set <Long > sessionIds = sessionRepository .findAllByCurriculumId (curriculum .getId ())
33
35
.stream ()
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public static KeywordsResponse createResponse(final List<Keyword> keywords) {
26
26
27
27
public static KeywordsResponse createResponseWithChildren (final List <Keyword > keywords ) {
28
28
List <KeywordResponse > keywordsResponse = keywords .stream ()
29
- .filter (it -> it . getParent () == null )
29
+ .filter (Keyword :: isRoot )
30
30
.map (KeywordResponse ::createWithAllChildResponse )
31
31
.collect (Collectors .toList ());
32
32
return new KeywordsResponse (keywordsResponse );
Original file line number Diff line number Diff line change @@ -124,6 +124,10 @@ private void validateKeywordParent(final Keyword parentKeyword) {
124
124
}
125
125
}
126
126
127
+ public boolean isRoot () {
128
+ return parent == null ;
129
+ }
130
+
127
131
public Long getParentIdOrNull () {
128
132
if (parent == null ) {
129
133
return null ;
You can’t perform that action at this time.
0 commit comments