Files
backend/gateway-service/src/main/java/com/drinkool/controller/EateryController.java
T
TakahashiNguyen 71575ec2ad
Release package / release (push) Successful in 30m26s
fix: add staff entity (#48)
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com>
Reviewed-on: #48
2026-05-07 14:45:44 +00:00

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);
}
}