|
|
@@ -1,10 +1,12 @@
|
|
|
package pl.sudra.configuration;
|
|
|
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import org.springframework.context.MessageSource;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
|
|
+import org.springframework.format.FormatterRegistry;
|
|
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
|
|
import org.springframework.web.servlet.LocaleResolver;
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
@@ -14,6 +16,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
|
|
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
|
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|
|
+import pl.sudra.service.AddressService;
|
|
|
+import pl.sudra.service.AppUserRoleService;
|
|
|
+import pl.sudra.utils.AddressConverter;
|
|
|
+import pl.sudra.utils.AppUserRoleConverter;
|
|
|
+import pl.sudra.utils.AppUserRoleListConverter;
|
|
|
|
|
|
import java.time.Duration;
|
|
|
import java.util.Locale;
|
|
|
@@ -67,4 +74,32 @@ public class SpringConfiguration implements WebMvcConfigurer {
|
|
|
bean.setValidationMessageSource(messageSource());
|
|
|
return bean;
|
|
|
}
|
|
|
+
|
|
|
+ @Resource(name = "addressService")
|
|
|
+ private AddressService addressService;
|
|
|
+
|
|
|
+ @Resource(name = "appUserRoleService")
|
|
|
+ private AppUserRoleService appUserRoleService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addFormatters(FormatterRegistry formatterRegistry) {
|
|
|
+ formatterRegistry.addConverter(getMyAddressConverter());
|
|
|
+ formatterRegistry.addConverter(getMyUserRoleConverter());
|
|
|
+ formatterRegistry.addConverter(getMyUserRoleListConverter());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public AddressConverter getMyAddressConverter() {
|
|
|
+ return new AddressConverter(addressService);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public AppUserRoleConverter getMyUserRoleConverter() {
|
|
|
+ return new AppUserRoleConverter(appUserRoleService);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public AppUserRoleListConverter getMyUserRoleListConverter() {
|
|
|
+ return new AppUserRoleListConverter(appUserRoleService);
|
|
|
+ }
|
|
|
}
|