-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d373409
commit ef33642
Showing
25 changed files
with
318 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import jakarta.annotation.PostConstruct; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
import org.springframework.stereotype.Service; | ||
import pmgkn.pescores.pescores.domain.entity.SchoolEntity; | ||
import pmgkn.pescores.pescores.domain.entity.UserEntity; | ||
import pmgkn.pescores.pescores.domain.entity.UserRoleEntity; | ||
import pmgkn.pescores.pescores.domain.entity.norms.*; | ||
|
@@ -29,14 +30,17 @@ public class DbInitService { | |
|
||
private final PasswordEncoder passwordEncoder; | ||
|
||
private final SchoolRepository schoolRepository; | ||
|
||
public DbInitService(UserRoleRepository userRoleRepository, | ||
DenseBallRepository denseBallRepository, | ||
JumpRepository jumpRepository, | ||
TTestRepository tTestRepository, | ||
ThirtyMetersRepository thirtyMetersRepository, | ||
TwoHundredMetersRepository twoHundredMetersRepository, | ||
UserRepository userRepository, | ||
PasswordEncoder passwordEncoder) { | ||
PasswordEncoder passwordEncoder, | ||
SchoolRepository schoolRepository) { | ||
this.userRoleRepository = userRoleRepository; | ||
this.denseBallRepository = denseBallRepository; | ||
this.jumpRepository = jumpRepository; | ||
|
@@ -45,10 +49,12 @@ public DbInitService(UserRoleRepository userRoleRepository, | |
this.twoHundredMetersRepository = twoHundredMetersRepository; | ||
this.userRepository = userRepository; | ||
this.passwordEncoder = passwordEncoder; | ||
this.schoolRepository = schoolRepository; | ||
} | ||
|
||
@PostConstruct | ||
public void init() { | ||
initSchool(); | ||
initRoles(); | ||
initSuperAdmin(); | ||
initDenseBall(); | ||
|
@@ -58,14 +64,21 @@ public void init() { | |
initThirtyMeters(); | ||
} | ||
|
||
private void initSchool() { | ||
if(this.schoolRepository.count()==0){ | ||
SchoolEntity school=new SchoolEntity().setCity("Kyustendil").setName("PMG Prof. Emanuil Ivanov"); | ||
this.schoolRepository.saveAndFlush(school); | ||
} | ||
} | ||
|
||
public void initSuperAdmin() { | ||
if (this.userRepository.count() == 0) { | ||
UserEntity user = new UserEntity() | ||
.setFirstName("Nikol") | ||
.setLastName("Georgieva") | ||
.setEmail("[email protected]") | ||
.setPassword(passwordEncoder.encode("nikol@superadmin")) | ||
.setSchool("PMG prof emanuil ivanov") | ||
.setSchool(this.schoolRepository.findSchoolEntityBySchoolName("PMG Prof. Emanuil Ivanov")) | ||
.setRoles(userRoleRepository.findAll()); | ||
this.userRepository.saveAndFlush(user); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.