37 lines
1.0 KiB
Java
37 lines
1.0 KiB
Java
|
package core;
|
||
|
|
||
|
import core.entities.RoleEntity;
|
||
|
import core.entities.UserRole;
|
||
|
import core.repositories.RoleRepository;
|
||
|
import core.repositories.UserRepository;
|
||
|
import core.services.PropertyService;
|
||
|
import org.springframework.boot.CommandLineRunner;
|
||
|
import org.springframework.boot.SpringApplication;
|
||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
|
import org.springframework.context.annotation.Bean;
|
||
|
|
||
|
@SpringBootApplication
|
||
|
public class DemoApplication{
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
SpringApplication.run(DemoApplication.class, args);
|
||
|
}
|
||
|
|
||
|
|
||
|
@Bean
|
||
|
public CommandLineRunner init(RoleRepository roleRepository, UserRepository userRepository, PropertyService propertyService) {
|
||
|
return args -> {
|
||
|
for (UserRole userRole : UserRole.values()) {
|
||
|
if(!roleRepository.existsByName(userRole)) {
|
||
|
roleRepository.save(new RoleEntity(userRole));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
propertyService.init();
|
||
|
|
||
|
FirstUserObserver observer = new FirstUserObserver(userRepository);
|
||
|
observer.start();
|
||
|
};
|
||
|
}
|
||
|
}
|