Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #50
This commit was merged in pull request #50.
This commit is contained in:
@@ -151,8 +151,8 @@
|
||||
<configuration>
|
||||
<argLine>@{argLine}</argLine>
|
||||
<systemPropertyVariables>
|
||||
<native.image.path>
|
||||
${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||
<native.image.path
|
||||
>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||
<java.util.logging.manager
|
||||
>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<maven.home>${maven.home}</maven.home>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.drinkool.controller;
|
||||
|
||||
import com.drinkool.services.FileService;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.io.File;
|
||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||
import org.jboss.resteasy.reactive.RestForm;
|
||||
|
||||
@Path("/api/file")
|
||||
public class FileController {
|
||||
|
||||
@Inject
|
||||
@RestClient
|
||||
FileService fileService;
|
||||
|
||||
@POST
|
||||
public Uni<Response> upload(@RestForm File file) {
|
||||
return fileService.upload(file);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{name}")
|
||||
public Uni<Response> get(@PathParam("name") String name) {
|
||||
return fileService.get(name);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.drinkool.Url;
|
||||
import com.drinkool.lib.dtos.Login;
|
||||
import com.drinkool.services.CustomerService;
|
||||
import com.drinkool.services.ManagerService;
|
||||
import com.drinkool.services.StaffService;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.POST;
|
||||
@@ -22,6 +23,10 @@ public class MainController extends BaseController {
|
||||
@RestClient
|
||||
CustomerService customerService;
|
||||
|
||||
@Inject
|
||||
@RestClient
|
||||
StaffService staffService;
|
||||
|
||||
@POST
|
||||
@Path(Url.Login)
|
||||
public Uni<Response> proxyLogin(Login input) {
|
||||
@@ -29,7 +34,12 @@ public class MainController extends BaseController {
|
||||
.login(input)
|
||||
.onFailure()
|
||||
.recoverWithUni(() -> {
|
||||
return customerService.login(input);
|
||||
return staffService
|
||||
.login(input)
|
||||
.onFailure()
|
||||
.recoverWithUni(() -> {
|
||||
return customerService.login(input);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.drinkool.controller;
|
||||
|
||||
import com.drinkool.InternalValue;
|
||||
import com.drinkool.Role;
|
||||
import com.drinkool.Url;
|
||||
import com.drinkool.lib.dtos.Signup;
|
||||
import com.drinkool.services.StaffService;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.HeaderParam;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||
|
||||
@Path("/api/" + Role.Staff)
|
||||
public class StaffController {
|
||||
|
||||
@Inject
|
||||
@RestClient
|
||||
StaffService staffService;
|
||||
|
||||
@POST
|
||||
@Path(Url.Signup)
|
||||
public Uni<Response> signup(
|
||||
Signup input,
|
||||
@HeaderParam(InternalValue.userId) UUID userId,
|
||||
@HeaderParam(InternalValue.role) String role
|
||||
) {
|
||||
return staffService.signup(input, userId, role);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||
import org.jboss.resteasy.reactive.RestForm;
|
||||
|
||||
@RegisterRestClient(configKey = "file")
|
||||
@Path("/")
|
||||
public interface FileService {
|
||||
@POST
|
||||
Uni<Response> upload(@RestForm File file);
|
||||
|
||||
@GET
|
||||
@Path("/{name}")
|
||||
Uni<Response> get(@PathParam("name") String name);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
import com.drinkool.InternalValue;
|
||||
import com.drinkool.Role;
|
||||
import com.drinkool.Url;
|
||||
import com.drinkool.lib.dtos.*;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.*;
|
||||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||
|
||||
@RegisterRestClient(configKey = "account")
|
||||
@Path(Role.Staff)
|
||||
public interface StaffService {
|
||||
@POST
|
||||
@Path(Url.Signup)
|
||||
Uni<Response> signup(
|
||||
Signup input,
|
||||
@HeaderParam(InternalValue.userId) UUID userId,
|
||||
@HeaderParam(InternalValue.role) String role
|
||||
);
|
||||
|
||||
@POST
|
||||
@Path(Url.Login)
|
||||
Uni<Response> login(Login input);
|
||||
|
||||
@GET
|
||||
@Path(Url.Me)
|
||||
Uni<Response> me(@HeaderParam(InternalValue.userId) UUID id);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ quarkus.native.additional-build-args=--future-defaults=all
|
||||
# Rest Client
|
||||
quarkus.rest-client.account.url=http://account-service
|
||||
quarkus.rest-client.eatery.url=http://eatery-service
|
||||
quarkus.rest-client.file.url=http://file-service
|
||||
|
||||
# GraphQL Client
|
||||
quarkus.smallrye-graphql-client.eatery.url=http://eatery-service/graphql
|
||||
|
||||
Reference in New Issue
Block a user