-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(main-api): 방이 가지고 있는 내부 아이피를 반환하는 api
- Loading branch information
1 parent
90f5382
commit c1c35d0
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
modules/main-api/src/main/java/com/whoz_in/main_api/query/private_ip/PrivateIpList.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,8 @@ | ||
package com.whoz_in.main_api.query.private_ip; | ||
|
||
import com.whoz_in.main_api.query.shared.application.Response; | ||
import java.util.List; | ||
|
||
public record PrivateIpList( | ||
List<String> ipList | ||
) implements Response {} |
7 changes: 7 additions & 0 deletions
7
modules/main-api/src/main/java/com/whoz_in/main_api/query/private_ip/PrivateIpListGet.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,7 @@ | ||
package com.whoz_in.main_api.query.private_ip; | ||
|
||
import com.whoz_in.main_api.query.shared.application.Query; | ||
|
||
public record PrivateIpListGet( | ||
String room | ||
) implements Query {} |
17 changes: 17 additions & 0 deletions
17
...main-api/src/main/java/com/whoz_in/main_api/query/private_ip/PrivateIpListGetHandler.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,17 @@ | ||
package com.whoz_in.main_api.query.private_ip; | ||
|
||
import com.whoz_in.main_api.query.shared.application.QueryHandler; | ||
import com.whoz_in.main_api.shared.application.Handler; | ||
import com.whoz_in.main_api.shared.caching.private_ip.PrivateIpStore; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Handler | ||
@RequiredArgsConstructor | ||
public class PrivateIpListGetHandler implements QueryHandler<PrivateIpListGet, PrivateIpList> { | ||
private final PrivateIpStore privateIpStore; | ||
@Override | ||
public PrivateIpList handle(PrivateIpListGet query) { | ||
return new PrivateIpList(privateIpStore.get(query.room()).values().stream() | ||
.toList()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ain-api/src/main/java/com/whoz_in/main_api/query/private_ip/PrivateIpQueryController.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,25 @@ | ||
package com.whoz_in.main_api.query.private_ip; | ||
|
||
import com.whoz_in.main_api.query.shared.application.QueryBus; | ||
import com.whoz_in.main_api.query.shared.presentation.QueryController; | ||
import com.whoz_in.main_api.shared.presentation.CrudResponseCode; | ||
import com.whoz_in.main_api.shared.presentation.ResponseEntityGenerator; | ||
import com.whoz_in.main_api.shared.presentation.SuccessBody; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1") | ||
public class PrivateIpQueryController extends QueryController { | ||
public PrivateIpQueryController(QueryBus queryBus) { | ||
super(queryBus); | ||
} | ||
|
||
@GetMapping("/private-ip/{room}") | ||
public ResponseEntity<SuccessBody<PrivateIpList>> getPrivateIps(@PathVariable String room){ | ||
return ResponseEntityGenerator.success(ask(new PrivateIpListGet(room)), CrudResponseCode.READ); | ||
} | ||
} |