41 lines
1.4 KiB
Java
41 lines
1.4 KiB
Java
package SuMoC.backend.seed.user;
|
|
|
|
import SuMoC.backend.security.dtos.UserRegistrationDTO;
|
|
import SuMoC.backend.security.services.AuthenticationService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.context.annotation.Profile;
|
|
import org.springframework.core.annotation.Order;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
@Profile("dev")
|
|
@Order(1)
|
|
public class DevUserSeeder implements CommandLineRunner {
|
|
|
|
private final AuthenticationService authenticationService;
|
|
|
|
@Autowired
|
|
public DevUserSeeder(AuthenticationService authenticationService) {
|
|
this.authenticationService = authenticationService;
|
|
}
|
|
|
|
@Override
|
|
public void run(String... args) throws Exception {
|
|
UserRegistrationDTO user1 = UserRegistrationDTO.builder()
|
|
.email("user1@email.com")
|
|
.publicName("Nutzer 1 Public")
|
|
.privateName("Nutzer 1 Privat")
|
|
.password("password1")
|
|
.build();
|
|
authenticationService.registerUser(user1);
|
|
UserRegistrationDTO user2 = UserRegistrationDTO.builder()
|
|
.email("user2@email.com")
|
|
.publicName("Nutzer 2 Public")
|
|
.privateName("Nutzer 2 Privat")
|
|
.password("password2")
|
|
.build();
|
|
authenticationService.registerUser(user2);
|
|
}
|
|
}
|