chore: update
This commit is contained in:
@@ -19,7 +19,7 @@ public class ManagerEntity extends UserModel {
|
|||||||
public List<StaffEntity> staffs = new ArrayList<>();
|
public List<StaffEntity> staffs = new ArrayList<>();
|
||||||
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
String bankAccount;
|
public String bankAccount;
|
||||||
|
|
||||||
public ManagerEntity() {
|
public ManagerEntity() {
|
||||||
super(Role.Manager);
|
super(Role.Manager);
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ public class ManagerService extends BaseService<ManagerEntity> {
|
|||||||
public Response signup(ManagerSignup input) {
|
public Response signup(ManagerSignup input) {
|
||||||
ManagerEntity newManager = new ManagerEntity();
|
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();
|
ManagerCreate message = new ManagerCreate();
|
||||||
message.id = newManager.id;
|
message.id = newManager.id;
|
||||||
@@ -68,8 +73,34 @@ public class ManagerService extends BaseService<ManagerEntity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{id}")
|
@Path("/{id}/payment-qr")
|
||||||
public Response getManagerById(@PathParam("id") UUID id) {
|
public Response getManagerPaymentQr(
|
||||||
return Response.ok(ManagerEntity.findById(id)).build();
|
@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
|
# Rest Client
|
||||||
quarkus.rest-client.eatery.url=http://eatery-service
|
quarkus.rest-client.eatery.url=http://eatery-service
|
||||||
|
quarkus.rest-client.account.url=http://account-service
|
||||||
|
|||||||
@@ -63,23 +63,23 @@ public class EateryService {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{eateryId}/{menuItemId}")
|
@Path("/{eateryId}/{menuItemId}")
|
||||||
public Response checkMenuItemExists(
|
public Response getMenuItemPrice(
|
||||||
@PathParam("eateryId") UUID eateryId,
|
@PathParam("eateryId") UUID eateryId,
|
||||||
@PathParam("menuItemId") UUID menuItemId
|
@PathParam("menuItemId") UUID menuItemId
|
||||||
) {
|
) {
|
||||||
long count = MenuItemEntity.find(
|
MenuItemEntity menuItem = MenuItemEntity.find(
|
||||||
"id = ?2 and eatery.id = ?1",
|
"id = ?1 and eatery.id = ?2",
|
||||||
eateryId,
|
menuItemId,
|
||||||
menuItemId
|
eateryId
|
||||||
).count();
|
).firstResult();
|
||||||
|
|
||||||
if (count == 0) {
|
if (menuItem == null) {
|
||||||
return Response.status(Response.Status.NOT_FOUND)
|
return Response.status(Response.Status.NOT_FOUND)
|
||||||
.entity("NotFoundMenuItem")
|
.entity("NotFoundMenuItem")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.ok().build();
|
return Response.ok(menuItem.price).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Incoming("manager-in")
|
@Incoming("manager-in")
|
||||||
|
|||||||
Reference in New Issue
Block a user