-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: 사용자는 허브 태그를 확인할 수 있다.
- Loading branch information
Showing
17 changed files
with
206 additions
and
40 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/seong/shoutlink/domain/hub/service/HubMapper.java
This file contains 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,31 @@ | ||
package com.seong.shoutlink.domain.hub.service; | ||
|
||
import com.seong.shoutlink.domain.hub.Hub; | ||
import com.seong.shoutlink.domain.hub.service.response.FindHubResponse; | ||
import com.seong.shoutlink.domain.hub.service.result.HubTagResponse; | ||
import com.seong.shoutlink.domain.hub.service.result.HubTagResult; | ||
import java.util.List; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class HubMapper { | ||
|
||
public static FindHubResponse findHubResponse(Hub hub, List<HubTagResult> tags) { | ||
List<HubTagResponse> hubTagResponses = tags.stream() | ||
.map(HubMapper::hubTagResponse) | ||
.toList(); | ||
return new FindHubResponse( | ||
hub.getHubId(), | ||
hub.getMasterId(), | ||
hub.getName(), | ||
hub.getDescription(), | ||
hub.isPrivate(), | ||
hubTagResponses | ||
); | ||
} | ||
|
||
private static HubTagResponse hubTagResponse(HubTagResult result) { | ||
return new HubTagResponse(result.tagId(), result.name()); | ||
} | ||
} |
This file contains 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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/seong/shoutlink/domain/hub/service/HubTagReader.java
This file contains 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,10 @@ | ||
package com.seong.shoutlink.domain.hub.service; | ||
|
||
import com.seong.shoutlink.domain.hub.Hub; | ||
import com.seong.shoutlink.domain.hub.service.result.HubTagResult; | ||
import java.util.List; | ||
|
||
public interface HubTagReader { | ||
|
||
List<HubTagResult> findTagsInHubs(List<Hub> hubs); | ||
} |
14 changes: 4 additions & 10 deletions
14
src/main/java/com/seong/shoutlink/domain/hub/service/response/FindHubResponse.java
This file contains 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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
package com.seong.shoutlink.domain.hub.service.response; | ||
|
||
import com.seong.shoutlink.domain.hub.Hub; | ||
import com.seong.shoutlink.domain.hub.service.result.HubTagResponse; | ||
import java.util.List; | ||
|
||
public record FindHubResponse( | ||
Long hubId, | ||
Long masterId, | ||
String name, | ||
String description, | ||
boolean isPrivate) { | ||
boolean isPrivate, | ||
List<HubTagResponse> tags) { | ||
|
||
public static FindHubResponse from(Hub hub) { | ||
return new FindHubResponse( | ||
hub.getHubId(), | ||
hub.getMasterId(), | ||
hub.getName(), | ||
hub.getDescription(), | ||
hub.isPrivate()); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
src/main/java/com/seong/shoutlink/domain/hub/service/response/FindHubsResponse.java
This file contains 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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
package com.seong.shoutlink.domain.hub.service.response; | ||
|
||
import com.seong.shoutlink.domain.hub.Hub; | ||
import java.util.List; | ||
|
||
public record FindHubsResponse(List<FindHubResponse> hubs, long totalElements, boolean hasNext) { | ||
|
||
public static FindHubsResponse of(List<Hub> hubs, long totalElements, boolean hasNext) { | ||
List<FindHubResponse> content = hubs.stream() | ||
.map(FindHubResponse::from) | ||
.toList(); | ||
return new FindHubsResponse(content, totalElements, hasNext); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/seong/shoutlink/domain/hub/service/result/HubTagResponse.java
This file contains 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,5 @@ | ||
package com.seong.shoutlink.domain.hub.service.result; | ||
|
||
public record HubTagResponse(Long tagId, String name) { | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/seong/shoutlink/domain/hub/service/result/HubTagResult.java
This file contains 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,6 @@ | ||
package com.seong.shoutlink.domain.hub.service.result; | ||
|
||
import com.seong.shoutlink.domain.hub.Hub; | ||
|
||
public record HubTagResult(Long tagId, String name, Hub hub) { | ||
} |
This file contains 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 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 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 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
2 changes: 1 addition & 1 deletion
2
.../shoutlink/fixture/StubHubRepository.java → ...ain/hub/repository/StubHubRepository.java
This file contains 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
src/test/java/com/seong/shoutlink/domain/hub/repository/StubHubTagReader.java
This file contains 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.seong.shoutlink.domain.hub.repository; | ||
|
||
import com.seong.shoutlink.domain.hub.Hub; | ||
import com.seong.shoutlink.domain.hub.service.HubTagReader; | ||
import com.seong.shoutlink.domain.hub.service.result.HubTagResult; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class StubHubTagReader implements HubTagReader { | ||
|
||
private final Map<Long, HubTagResult> hubTagMap = new HashMap<>(); | ||
|
||
public void stub(HubTagResult... results) { | ||
for (HubTagResult result : results) { | ||
hubTagMap.put((long) (hubTagMap.size()+1), result); | ||
} | ||
} | ||
|
||
@Override | ||
public List<HubTagResult> findTagsInHubs(List<Hub> hubs) { | ||
return hubTagMap.values().stream().toList(); | ||
} | ||
} |
Oops, something went wrong.