chore: update
This commit is contained in:
@@ -19,7 +19,7 @@ public class ManagerEntity extends UserModel {
|
||||
public List<StaffEntity> staffs = new ArrayList<>();
|
||||
|
||||
@Column(nullable = true)
|
||||
String bankAccount;
|
||||
public String bankAccount;
|
||||
|
||||
public ManagerEntity() {
|
||||
super(Role.Manager);
|
||||
|
||||
@@ -28,7 +28,12 @@ public class ManagerService extends BaseService<ManagerEntity> {
|
||||
public Response signup(ManagerSignup input) {
|
||||
ManagerEntity newManager = new ManagerEntity();
|
||||
|
||||
newManager.signup(input.name, input.phone, input.bankAccount, input.password);
|
||||
newManager.signup(
|
||||
input.name,
|
||||
input.phone,
|
||||
input.bankAccount,
|
||||
input.password
|
||||
);
|
||||
|
||||
ManagerCreate message = new ManagerCreate();
|
||||
message.id = newManager.id;
|
||||
@@ -68,8 +73,34 @@ public class ManagerService extends BaseService<ManagerEntity> {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
public Response getManagerById(@PathParam("id") UUID id) {
|
||||
return Response.ok(ManagerEntity.findById(id)).build();
|
||||
@Path("/{id}/payment-qr")
|
||||
public Response getManagerPaymentQr(
|
||||
@PathParam("id") UUID id,
|
||||
@QueryParam("amount") Long amount,
|
||||
@QueryParam("cartId") String cartId
|
||||
) {
|
||||
ManagerEntity manager = ManagerEntity.findById(id);
|
||||
if (manager == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity("ManagerNotFound")
|
||||
.build();
|
||||
}
|
||||
|
||||
if (manager.bankAccount == null || manager.bankAccount.isEmpty()) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity("ManagerHasNotConfiguredBankInfo")
|
||||
.build();
|
||||
}
|
||||
|
||||
String description = cartId;
|
||||
|
||||
return Response.ok(
|
||||
String.format(
|
||||
"https://img.vietqr.io/image/%s-compact.png?amount=%d&addInfo=%s",
|
||||
manager.bankAccount,
|
||||
amount,
|
||||
description
|
||||
)
|
||||
).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.drinkool.controllers;
|
||||
|
||||
import com.drinkool.Role;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.ws.rs.GET;
|
||||
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(Role.Manager)
|
||||
public interface ManagerController {
|
||||
@GET
|
||||
@Path(Role.Manager + "/{id}/payment-qr")
|
||||
public Uni<Response> getManagerPaymentQr(
|
||||
@PathParam("id") UUID id,
|
||||
@QueryParam("amount") Long amount,
|
||||
@QueryParam("cartId") String cartId
|
||||
);
|
||||
}
|
||||
@@ -21,3 +21,4 @@ quarkus.redis.hosts=redis://${REDIS_SERVICE_SERVICE_HOST:localhost}:${REDIS_SERV
|
||||
|
||||
# Rest Client
|
||||
quarkus.rest-client.eatery.url=http://eatery-service
|
||||
quarkus.rest-client.account.url=http://account-service
|
||||
|
||||
@@ -63,23 +63,23 @@ public class EateryService {
|
||||
|
||||
@GET
|
||||
@Path("/{eateryId}/{menuItemId}")
|
||||
public Response checkMenuItemExists(
|
||||
public Response getMenuItemPrice(
|
||||
@PathParam("eateryId") UUID eateryId,
|
||||
@PathParam("menuItemId") UUID menuItemId
|
||||
) {
|
||||
long count = MenuItemEntity.find(
|
||||
"id = ?2 and eatery.id = ?1",
|
||||
eateryId,
|
||||
menuItemId
|
||||
).count();
|
||||
MenuItemEntity menuItem = MenuItemEntity.find(
|
||||
"id = ?1 and eatery.id = ?2",
|
||||
menuItemId,
|
||||
eateryId
|
||||
).firstResult();
|
||||
|
||||
if (count == 0) {
|
||||
if (menuItem == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity("NotFoundMenuItem")
|
||||
.build();
|
||||
}
|
||||
|
||||
return Response.ok().build();
|
||||
return Response.ok(menuItem.price).build();
|
||||
}
|
||||
|
||||
@Incoming("manager-in")
|
||||
|
||||
Reference in New Issue
Block a user