fix: add send review and get reviews (#45)
Release package / release (push) Successful in 15m47s
Release package / release (push) Successful in 15m47s
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #45
This commit was merged in pull request #45.
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
package com.drinkool.controller;
|
||||
|
||||
import com.drinkool.InternalValue;
|
||||
import com.drinkool.Url;
|
||||
import com.drinkool.enums.SortBy;
|
||||
import com.drinkool.lib.dtos.GraphqlDto;
|
||||
import com.drinkool.lib.dtos.SendReview;
|
||||
import com.drinkool.services.ReviewService;
|
||||
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
|
||||
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClientBuilder;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.json.bind.Jsonb;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||
|
||||
@Path("/api/eatery")
|
||||
public class EateryController {
|
||||
@@ -23,6 +34,25 @@ public class EateryController {
|
||||
@Inject
|
||||
Jsonb jsonb;
|
||||
|
||||
@Inject
|
||||
@RestClient
|
||||
ReviewService reviewService;
|
||||
|
||||
@GET
|
||||
@Path(Url.Review + "/{eateryId}")
|
||||
Uni<Response> getReviewsByEatery(
|
||||
@PathParam("eateryId") UUID eateryId,
|
||||
@QueryParam("sort") @DefaultValue("LATEST") SortBy sortBy
|
||||
) {
|
||||
return reviewService.getReviewsByEatery(eateryId, sortBy);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path(Url.Review)
|
||||
Uni<Response> receiveReview(SendReview input) {
|
||||
return reviewService.receiveReview(input);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/graphql")
|
||||
public Response forward(
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
import com.drinkool.Url;
|
||||
import com.drinkool.enums.SortBy;
|
||||
import com.drinkool.lib.dtos.SendReview;
|
||||
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||
|
||||
@RegisterRestClient(configKey = "eatery")
|
||||
@Path(Url.Review)
|
||||
public interface ReviewService {
|
||||
@GET
|
||||
@Path("/{eateryId}")
|
||||
public Uni<Response> getReviewsByEatery(
|
||||
@PathParam("eateryId") UUID eateryId,
|
||||
@QueryParam("sort") @DefaultValue("LATEST") SortBy sortBy
|
||||
);
|
||||
|
||||
@POST
|
||||
public Uni<Response> receiveReview(SendReview input);
|
||||
}
|
||||
@@ -14,6 +14,7 @@ quarkus.native.additional-build-args=--future-defaults=all
|
||||
|
||||
# Rest Client
|
||||
quarkus.rest-client.account.url=http://account-service
|
||||
quarkus.rest-client.eatery.url=http://eatery-service
|
||||
|
||||
# GraphQL Client
|
||||
quarkus.smallrye-graphql-client.eatery.url=http://eatery-service/graphql
|
||||
Reference in New Issue
Block a user