starting request service
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account;
|
||||
|
||||
public interface AccountService{
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package dev.mars3142.fhq.account.repositories;
|
||||
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.LoginResponse;
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.AccountDeleteResponse;
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.AccountRegisterResponse;
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.RefreshTokenResponse;
|
||||
|
||||
public interface AccountRepository {
|
||||
|
||||
AccountRegisterResponse register(String username, String email, String password);
|
||||
|
||||
LoginResponse login(String username, String password);
|
||||
|
||||
RefreshTokenResponse refreshToken(String token);
|
||||
|
||||
AccountDeleteResponse delete(String token);
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl;
|
||||
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.AccountRegisterResponse;
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.LoginResponse;
|
||||
import dev.mars3142.fhq.account.repositories.AccountRepository;
|
||||
import dev.mars3142.fhq.account.repositories.impl.requests.AccountDeleteRequest;
|
||||
import dev.mars3142.fhq.account.repositories.impl.requests.LoginRequest;
|
||||
import dev.mars3142.fhq.account.repositories.impl.requests.RefreshTokenRequest;
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.AccountDeleteResponse;
|
||||
import dev.mars3142.fhq.account.repositories.impl.responses.RefreshTokenResponse;
|
||||
import dev.mars3142.fhq.account.repositories.impl.requests.AccountRegisterRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AccountRepositoryImpl implements AccountRepository {
|
||||
|
||||
private final RestClient client;
|
||||
|
||||
@Override
|
||||
public AccountRegisterResponse register(String username, String email, String password) {
|
||||
val request = new AccountRegisterRequest(username, email, password);
|
||||
return client
|
||||
.post()
|
||||
.uri("/v1/account/register")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(AccountRegisterResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginResponse login(String email, String password) {
|
||||
val request = new LoginRequest(email, password);
|
||||
return client
|
||||
.post()
|
||||
.uri("/v1/account/login")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(LoginResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefreshTokenResponse refreshToken(String token) {
|
||||
val request = new RefreshTokenRequest(token);
|
||||
return client
|
||||
.post()
|
||||
.uri("/v1/account/refresh")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(RefreshTokenResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountDeleteResponse delete(String token) {
|
||||
val request = new AccountDeleteRequest(token);
|
||||
return client
|
||||
.post()
|
||||
.uri("/v1/account/delete")
|
||||
.body(request)
|
||||
.retrieve()
|
||||
.body(AccountDeleteResponse.class);
|
||||
}
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||
|
||||
public record AccountDeleteRequest(String token) {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||
|
||||
public record AccountRegisterRequest(String username, String email, String password) {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||
|
||||
public record LoginRequest(String email, String password) {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.requests;
|
||||
|
||||
public record RefreshTokenRequest(String token) {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||
|
||||
public record AccountDeleteResponse() {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||
|
||||
public record AccountRegisterResponse() {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||
|
||||
public record LoginResponse() {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package dev.mars3142.fhq.account.repositories.impl.responses;
|
||||
|
||||
public record RefreshTokenResponse() {
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package dev.mars3142.fhq.account.services;
|
||||
|
||||
import dev.mars3142.fhq.account.repositories.AccountRepository;
|
||||
import dev.mars3142.fhq.account.AccountService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AccountServiceImpl implements AccountService {
|
||||
|
||||
private final AccountRepository repository;
|
||||
|
||||
}
|
18
src/main/java/dev/mars3142/fhq/config/AppConfig.java
Normal file
18
src/main/java/dev/mars3142/fhq/config/AppConfig.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package dev.mars3142.fhq.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
@Configuration
|
||||
public class AppConfig {
|
||||
|
||||
@Value("${backend.uri}")
|
||||
private String baseUri;
|
||||
|
||||
@Bean
|
||||
public RestClient restClient() {
|
||||
return RestClient.builder().baseUrl(baseUri).build();
|
||||
}
|
||||
}
|
@@ -26,8 +26,8 @@ import com.vaadin.flow.theme.lumo.LumoUtility.Padding;
|
||||
import com.vaadin.flow.theme.lumo.LumoUtility.TextColor;
|
||||
import com.vaadin.flow.theme.lumo.LumoUtility.Whitespace;
|
||||
import com.vaadin.flow.theme.lumo.LumoUtility.Width;
|
||||
import dev.mars3142.fhq.views.checkoutform.CheckoutFormView;
|
||||
import dev.mars3142.fhq.views.myview.MyViewView;
|
||||
import dev.mars3142.fhq.views.checkout_form.CheckoutFormView;
|
||||
import dev.mars3142.fhq.views.my_view.MyViewView;
|
||||
import org.vaadin.lineawesome.LineAwesomeIcon;
|
||||
|
||||
/**
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package dev.mars3142.fhq.views.checkoutform;
|
||||
package dev.mars3142.fhq.views.checkout_form;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
@@ -1,4 +1,4 @@
|
||||
package dev.mars3142.fhq.views.landingpage;
|
||||
package dev.mars3142.fhq.views.landing_page;
|
||||
|
||||
import com.vaadin.flow.component.applayout.AppLayout;
|
||||
import com.vaadin.flow.component.html.Div;
|
@@ -0,0 +1,17 @@
|
||||
package dev.mars3142.fhq.views.landing_page;
|
||||
|
||||
import com.vaadin.flow.component.Composite;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@PageTitle("Firmware HQ")
|
||||
@Route(value = "", layout = LandingPageLayout.class)
|
||||
@Slf4j
|
||||
public class LandingPageView extends Composite<VerticalLayout> {
|
||||
|
||||
public LandingPageView() {
|
||||
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package dev.mars3142.fhq.views.landingpage;
|
||||
|
||||
import com.vaadin.flow.component.Composite;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
@PageTitle("Firmware HQ")
|
||||
@Route(value = "", layout = LandingPageLayout.class)
|
||||
@Slf4j
|
||||
public class LandingPageView extends Composite<VerticalLayout> {
|
||||
public LandingPageView() {
|
||||
val client = RestClient
|
||||
.builder()
|
||||
.baseUrl("https://user-service-ggxookssmq-ew.a.run.app/v1")
|
||||
.build();
|
||||
val response = client.get()
|
||||
.uri("/users")
|
||||
.retrieve()
|
||||
.body(String.class);
|
||||
log.info("Response: {}", response);
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package dev.mars3142.fhq.views.myview;
|
||||
package dev.mars3142.fhq.views.my_view;
|
||||
|
||||
import com.vaadin.flow.component.Composite;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
Reference in New Issue
Block a user