fix: merge customer and manager login (#38)
Release package / release (push) Successful in 13m32s

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com>
Reviewed-on: #38
This commit was merged in pull request #38.
This commit is contained in:
2026-04-26 16:45:42 +00:00
parent 08e7242382
commit e60c0b89b9
4 changed files with 38 additions and 15 deletions
@@ -11,7 +11,7 @@ import java.util.*;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@Path("/api/" + Role.Customer)
public class CustomerController extends BaseController {
public class CustomerController {
@Inject
@RestClient
@@ -23,12 +23,6 @@ public class CustomerController extends BaseController {
return accountService.signup(input);
}
@POST
@Path(Url.Login)
public Uni<Response> proxyLogin(Login input) {
return accountService.login(input);
}
@POST
@Path(Url.QuickSignup)
public Uni<Response> proxyQuickSignup(QuickSignup input) {
@@ -0,0 +1,35 @@
package com.drinkool.controller;
import com.drinkool.Url;
import com.drinkool.dtos.Login;
import com.drinkool.services.CustomerService;
import com.drinkool.services.ManagerService;
import io.smallrye.mutiny.Uni;
import jakarta.inject.Inject;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@Path("/api")
public class MainController extends BaseController {
@Inject
@RestClient
ManagerService managerService;
@Inject
@RestClient
CustomerService customerService;
@POST
@Path(Url.Login)
public Uni<Response> proxyLogin(Login input) {
return managerService
.login(input)
.onFailure()
.recoverWithUni(() -> {
return customerService.login(input);
});
}
}
@@ -11,7 +11,7 @@ import java.util.*;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@Path("/api/" + Role.Manager)
public class ManagerController extends BaseController {
public class ManagerController {
@Inject
@RestClient
@@ -23,12 +23,6 @@ public class ManagerController extends BaseController {
return managerService.signup(input);
}
@POST
@Path(Url.Login)
public Uni<Response> proxyLogin(Login input) {
return managerService.login(input);
}
@GET
public Uni<Response> me(@HeaderParam(InternalValue.userId) UUID id) {
return managerService.me(id);
@@ -16,7 +16,7 @@ public class BaseControllerTest {
public void testLogoutShouldClearCookie() {
given()
.when()
.post("/api/" + Role.Customer + Url.Logout)
.post("/api" + Url.Logout)
.then()
.statusCode(204)
.header("Set-Cookie", containsString(InternalValue.cookieName))