From bac0a79cba4f6ddf5211bceaad236de1d8add853 Mon Sep 17 00:00:00 2001 From: nashtech-huyphamphu Date: Thu, 19 Sep 2024 13:52:40 +0700 Subject: [PATCH] #882 Create a shared project --- .../java/com/yas/cart}/config/CorsConfig.java | 2 +- .../yas/cart}/config/RestClientConfig.java | 2 +- .../com/yas/customer/config/CorsConfig.java | 20 +++++++++++++++++++ .../yas/customer/config/RestClientConfig.java | 15 ++++++++++++++ .../com/yas/inventory/config/CorsConfig.java | 20 +++++++++++++++++++ .../inventory/config/RestClientConfig.java | 15 ++++++++++++++ .../com/yas/location/config/CorsConfig.java | 20 +++++++++++++++++++ .../yas/location/config/RestClientConfig.java | 15 ++++++++++++++ .../com/yas/product/config/CorsConfig.java | 20 +++++++++++++++++++ 9 files changed, 127 insertions(+), 2 deletions(-) rename {common-library/src/main/java/com/yas/commonlibrary => cart/src/main/java/com/yas/cart}/config/CorsConfig.java (94%) rename {common-library/src/main/java/com/yas/commonlibrary => cart/src/main/java/com/yas/cart}/config/RestClientConfig.java (89%) create mode 100644 customer/src/main/java/com/yas/customer/config/CorsConfig.java create mode 100644 customer/src/main/java/com/yas/customer/config/RestClientConfig.java create mode 100644 inventory/src/main/java/com/yas/inventory/config/CorsConfig.java create mode 100644 inventory/src/main/java/com/yas/inventory/config/RestClientConfig.java create mode 100644 location/src/main/java/com/yas/location/config/CorsConfig.java create mode 100644 location/src/main/java/com/yas/location/config/RestClientConfig.java create mode 100644 product/src/main/java/com/yas/product/config/CorsConfig.java diff --git a/common-library/src/main/java/com/yas/commonlibrary/config/CorsConfig.java b/cart/src/main/java/com/yas/cart/config/CorsConfig.java similarity index 94% rename from common-library/src/main/java/com/yas/commonlibrary/config/CorsConfig.java rename to cart/src/main/java/com/yas/cart/config/CorsConfig.java index b17001b554..87af701f45 100644 --- a/common-library/src/main/java/com/yas/commonlibrary/config/CorsConfig.java +++ b/cart/src/main/java/com/yas/cart/config/CorsConfig.java @@ -1,4 +1,4 @@ -package com.yas.commonlibrary.config; +package com.yas.cart.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/common-library/src/main/java/com/yas/commonlibrary/config/RestClientConfig.java b/cart/src/main/java/com/yas/cart/config/RestClientConfig.java similarity index 89% rename from common-library/src/main/java/com/yas/commonlibrary/config/RestClientConfig.java rename to cart/src/main/java/com/yas/cart/config/RestClientConfig.java index 52cabe60a0..191499ac48 100644 --- a/common-library/src/main/java/com/yas/commonlibrary/config/RestClientConfig.java +++ b/cart/src/main/java/com/yas/cart/config/RestClientConfig.java @@ -1,4 +1,4 @@ -package com.yas.commonlibrary.config; +package com.yas.cart.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/customer/src/main/java/com/yas/customer/config/CorsConfig.java b/customer/src/main/java/com/yas/customer/config/CorsConfig.java new file mode 100644 index 0000000000..f9e665a312 --- /dev/null +++ b/customer/src/main/java/com/yas/customer/config/CorsConfig.java @@ -0,0 +1,20 @@ +package com.yas.customer.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig { + @Bean + public WebMvcConfigurer corsConfigure() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("*").allowedOrigins("*") + .allowedHeaders("*"); + } + }; + } +} diff --git a/customer/src/main/java/com/yas/customer/config/RestClientConfig.java b/customer/src/main/java/com/yas/customer/config/RestClientConfig.java new file mode 100644 index 0000000000..317d233766 --- /dev/null +++ b/customer/src/main/java/com/yas/customer/config/RestClientConfig.java @@ -0,0 +1,15 @@ +package com.yas.customer.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestClient; + +@Configuration +public class RestClientConfig { + + @Bean + public RestClient restClient() { + return RestClient.builder().build(); + } + +} diff --git a/inventory/src/main/java/com/yas/inventory/config/CorsConfig.java b/inventory/src/main/java/com/yas/inventory/config/CorsConfig.java new file mode 100644 index 0000000000..6c18759dcf --- /dev/null +++ b/inventory/src/main/java/com/yas/inventory/config/CorsConfig.java @@ -0,0 +1,20 @@ +package com.yas.inventory.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig { + @Bean + public WebMvcConfigurer corsConfigure() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("*").allowedOrigins("*") + .allowedHeaders("*"); + } + }; + } +} diff --git a/inventory/src/main/java/com/yas/inventory/config/RestClientConfig.java b/inventory/src/main/java/com/yas/inventory/config/RestClientConfig.java new file mode 100644 index 0000000000..ba18958ecc --- /dev/null +++ b/inventory/src/main/java/com/yas/inventory/config/RestClientConfig.java @@ -0,0 +1,15 @@ +package com.yas.inventory.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestClient; + +@Configuration +public class RestClientConfig { + + @Bean + public RestClient restClient() { + return RestClient.builder().build(); + } + +} diff --git a/location/src/main/java/com/yas/location/config/CorsConfig.java b/location/src/main/java/com/yas/location/config/CorsConfig.java new file mode 100644 index 0000000000..7b7f9d35bf --- /dev/null +++ b/location/src/main/java/com/yas/location/config/CorsConfig.java @@ -0,0 +1,20 @@ +package com.yas.location.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig { + @Bean + public WebMvcConfigurer corsConfigure() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("*").allowedOrigins("*") + .allowedHeaders("*"); + } + }; + } +} diff --git a/location/src/main/java/com/yas/location/config/RestClientConfig.java b/location/src/main/java/com/yas/location/config/RestClientConfig.java new file mode 100644 index 0000000000..d5ad3b0a17 --- /dev/null +++ b/location/src/main/java/com/yas/location/config/RestClientConfig.java @@ -0,0 +1,15 @@ +package com.yas.location.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestClient; + +@Configuration +public class RestClientConfig { + + @Bean + public RestClient restClient() { + return RestClient.builder().build(); + } + +} diff --git a/product/src/main/java/com/yas/product/config/CorsConfig.java b/product/src/main/java/com/yas/product/config/CorsConfig.java new file mode 100644 index 0000000000..4996d15f98 --- /dev/null +++ b/product/src/main/java/com/yas/product/config/CorsConfig.java @@ -0,0 +1,20 @@ +package com.yas.product.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig { + @Bean + public WebMvcConfigurer corsConfigure() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("*").allowedOrigins("*") + .allowedHeaders("*"); + } + }; + } +}