-
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.
Add loading crates in Warehouse Storage tab
- Loading branch information
1 parent
813e658
commit e34eba1
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
src/main/java/org/chainoptim/desktop/features/warehouse/service/CrateService.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,13 @@ | ||
package org.chainoptim.desktop.features.warehouse.service; | ||
|
||
import org.chainoptim.desktop.features.warehouse.model.Compartment; | ||
import org.chainoptim.desktop.features.warehouse.model.Crate; | ||
import org.chainoptim.desktop.shared.httphandling.Result; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface CrateService { | ||
|
||
CompletableFuture<Result<List<Crate>>> getCratesByOrganizationId(Integer organizationId); | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/org/chainoptim/desktop/features/warehouse/service/CrateServiceImpl.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,38 @@ | ||
package org.chainoptim.desktop.features.warehouse.service; | ||
|
||
import org.chainoptim.desktop.core.user.service.TokenManager; | ||
import org.chainoptim.desktop.features.warehouse.model.Compartment; | ||
import org.chainoptim.desktop.features.warehouse.model.Crate; | ||
import org.chainoptim.desktop.shared.httphandling.RequestBuilder; | ||
import org.chainoptim.desktop.shared.httphandling.RequestHandler; | ||
import org.chainoptim.desktop.shared.httphandling.Result; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.google.inject.Inject; | ||
|
||
import java.net.http.HttpRequest; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class CrateServiceImpl implements CrateService { | ||
|
||
private final RequestBuilder requestBuilder; | ||
private final RequestHandler requestHandler; | ||
private final TokenManager tokenManager; | ||
|
||
@Inject | ||
public CrateServiceImpl(RequestBuilder requestBuilder, | ||
RequestHandler requestHandler, | ||
TokenManager tokenManager) { | ||
this.requestBuilder = requestBuilder; | ||
this.requestHandler = requestHandler; | ||
this.tokenManager = tokenManager; | ||
} | ||
|
||
public CompletableFuture<Result<List<Crate>>> getCratesByOrganizationId(Integer organizationId) { | ||
String routeAddress = "http://localhost:8080/api/v1/crates/organization/" + organizationId.toString(); | ||
|
||
HttpRequest request = requestBuilder.buildReadRequest(routeAddress, tokenManager.getToken()); | ||
|
||
return requestHandler.sendRequest(request, new TypeReference<List<Crate>>() {}); | ||
} | ||
} |
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