добавил создание пользователя по умолчанию при первом старте
This commit is contained in:
parent
5621b809f7
commit
7c47c79823
@ -1,13 +1,30 @@
|
||||
package com.gipro.giprolab;
|
||||
|
||||
import com.gipro.giprolab.models.UserDto;
|
||||
import com.gipro.giprolab.services.UserService;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
@SpringBootApplication
|
||||
public class GiprolabApplication {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public GiprolabApplication(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GiprolabApplication.class, args);
|
||||
}
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void doSomethingAfterStartup() {
|
||||
if (userService.getUserByLogin("user@user.ru") == null) {
|
||||
userService.createDefaultRoles();
|
||||
userService.createUser(new UserDto("user@user.ru", "user"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user