Skip to content

Commit

Permalink
Add optional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Fagorym committed Dec 20, 2023
1 parent a6b3e0a commit 57e12ed
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ru.nsu.fit.directors.userservice.model.User;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.time.LocalDateTime;
import java.util.Collections;
Expand Down Expand Up @@ -48,14 +49,15 @@ public void cancelOrder(Long orderId) {

@Override
@Nonnull
public List<ResponseOrderDto> getOrders(Integer status) {
public List<ResponseOrderDto> getOrders(@Nullable Integer status) {
User loggedUser = securityService.getLoggedInUser();
return orderApi.syncListGetWithParams(
uriBuilder -> uriBuilder.path("/order")
.queryParam("userId", loggedUser.getId())
.queryParam("status", status)
.queryParamIfPresent("status", Optional.ofNullable(status))
.build(),
new ParameterizedTypeReference<>() {}
new ParameterizedTypeReference<>() {
}
);

}
Expand Down Expand Up @@ -94,7 +96,8 @@ private List<LocalDateTime> getValidTimes(RequestOrderDto requestOrderDto) {
uriBuilder -> uriBuilder.path("/establishment/internal/time")
.queryParam("establishmentId", requestOrderDto.getEstablishmentId())
.build(),
new ParameterizedTypeReference<>() {}
new ParameterizedTypeReference<>() {
}
);
}
}

0 comments on commit 57e12ed

Please sign in to comment.