chore: update
This commit is contained in:
@@ -3,6 +3,7 @@ package com.drinkool.entities;
|
||||
import com.drinkool.Role;
|
||||
import com.drinkool.models.UserModel;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +18,22 @@ public class ManagerEntity extends UserModel {
|
||||
)
|
||||
public List<StaffEntity> staffs = new ArrayList<>();
|
||||
|
||||
@Column(nullable = true)
|
||||
String bankAccount;
|
||||
|
||||
public ManagerEntity() {
|
||||
super(Role.Manager);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void signup(
|
||||
String name,
|
||||
String phone,
|
||||
String bankAccount,
|
||||
String rawPassword
|
||||
) {
|
||||
this.bankAccount = bankAccount;
|
||||
|
||||
super.signup(name, phone, rawPassword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ManagerService extends BaseService<ManagerEntity> {
|
||||
public Response signup(ManagerSignup input) {
|
||||
ManagerEntity newManager = new ManagerEntity();
|
||||
|
||||
newManager.signup(input.name, input.phone, input.password);
|
||||
newManager.signup(input.name, input.phone, input.bankAccount, input.password);
|
||||
|
||||
ManagerCreate message = new ManagerCreate();
|
||||
message.id = newManager.id;
|
||||
|
||||
@@ -129,6 +129,10 @@
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-rest-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-rest-client-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-container-image-docker</artifactId>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.drinkool.controllers;
|
||||
|
||||
import com.drinkool.Role;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||
|
||||
@RegisterRestClient(configKey = "account")
|
||||
@Path(Role.Manager)
|
||||
public interface AccountController {
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
public Response getManagerById(@PathParam("id") UUID id);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.drinkool.services;
|
||||
|
||||
import com.drinkool.InternalValue;
|
||||
import com.drinkool.Role;
|
||||
import com.drinkool.controllers.AccountController;
|
||||
import com.drinkool.dtos.AddMenuItem;
|
||||
import com.drinkool.dtos.DtoMapper;
|
||||
import com.drinkool.dtos.OrderBill;
|
||||
@@ -22,12 +23,14 @@ import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.microprofile.graphql.GraphQLApi;
|
||||
import org.eclipse.microprofile.graphql.Mutation;
|
||||
import org.eclipse.microprofile.graphql.Name;
|
||||
import org.eclipse.microprofile.graphql.Query;
|
||||
import org.eclipse.microprofile.reactive.messaging.Incoming;
|
||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||
|
||||
@ApplicationScoped
|
||||
@GraphQLApi
|
||||
@@ -40,6 +43,10 @@ public class EateryService {
|
||||
@Inject
|
||||
HttpServerRequest request;
|
||||
|
||||
@Inject
|
||||
@RestClient
|
||||
AccountController accountController;
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
public Response checkEateryExists(@PathParam("id") UUID id) {
|
||||
@@ -187,6 +194,17 @@ public class EateryService {
|
||||
}
|
||||
}
|
||||
|
||||
return Response.ok(new OrderBill(details, grandTotal, "")).build();
|
||||
EateryEntity eatery = EateryEntity.findById(eateryId);
|
||||
|
||||
try (Response response = accountController.getManagerById(eatery.ownerId)) {
|
||||
if (response.getStatus() == 200) {
|
||||
Map<String, Object> data = response.readEntity(Map.class);
|
||||
String bankNo = (String) data.get("bankAccount");
|
||||
|
||||
return Response.ok(new OrderBill(details, grandTotal, bankNo)).build();
|
||||
}
|
||||
|
||||
return Response.serverError().entity(response.getEntity()).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,12 @@ quarkus.native.additional-build-args=--future-defaults=all
|
||||
|
||||
# Kafka
|
||||
%prod.mp.messaging.connector.smallrye-kafka.bootstrap.servers=${KAFKA_SERVICE_SERVICE_HOST:host.docker.internal}:9092
|
||||
mp.messaging.incoming.manager-in.connector=smallrye-in-memory
|
||||
|
||||
## Create restaurant topic
|
||||
mp.messaging.incoming.manager-in.connector=smallrye-kafka
|
||||
mp.messaging.incoming.manager-in.topic=create-restaurant
|
||||
mp.messaging.incoming.manager-in.auto.offset.reset=earliest
|
||||
quarkus.messaging.kafka.serializer-generation.enabled=true
|
||||
|
||||
# Rest Client
|
||||
quarkus.rest-client.account.url=http://account-service
|
||||
|
||||
Reference in New Issue
Block a user