71575ec2ad
Release package / release (push) Successful in 30m26s
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #48
65 lines
1.7 KiB
Java
65 lines
1.7 KiB
Java
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.mutiny.Uni;
|
|
import jakarta.inject.Inject;
|
|
import jakarta.ws.rs.DefaultValue;
|
|
import jakarta.ws.rs.GET;
|
|
import jakarta.ws.rs.HeaderParam;
|
|
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.Response;
|
|
import java.util.UUID;
|
|
import lombok.Getter;
|
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
|
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
|
|
|
@Path("/api/eatery")
|
|
@Getter
|
|
public class EateryController extends GraphqlBase {
|
|
|
|
@ConfigProperty(name = "quarkus.smallrye-graphql-client.eatery.url")
|
|
String graphqlUrl;
|
|
|
|
@Inject
|
|
@RestClient
|
|
ReviewService reviewService;
|
|
|
|
@GET
|
|
@Path(Url.Review + "/{eateryId}")
|
|
public Uni<Response> getReviewsByEatery(
|
|
@PathParam("eateryId") UUID eateryId,
|
|
@QueryParam("sort") @DefaultValue("LATEST") SortBy sortBy
|
|
) {
|
|
return reviewService.getReviewsByEatery(eateryId, sortBy);
|
|
}
|
|
|
|
@POST
|
|
@Path(Url.Review)
|
|
public Uni<Response> receiveReview(
|
|
SendReview input,
|
|
@HeaderParam(InternalValue.userId) UUID userId,
|
|
@HeaderParam(InternalValue.role) String role
|
|
) {
|
|
return reviewService.receiveReview(input, userId, role);
|
|
}
|
|
|
|
@POST
|
|
@Path("/graphql")
|
|
public Response forward(
|
|
GraphqlDto gqlRequest,
|
|
@Context HttpHeaders httpHeaders
|
|
) {
|
|
return send(gqlRequest, httpHeaders);
|
|
}
|
|
}
|