dbinit modify
This commit is contained in:
parent
3873ef7754
commit
78037ab0d4
|
@ -1,7 +1,9 @@
|
|||
package com.totopia.server.init;
|
||||
|
||||
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
||||
import com.totopia.server.modules.game.entity.LeagueEntity;
|
||||
import com.totopia.server.modules.game.entity.SportsEntity;
|
||||
import com.totopia.server.modules.game.repository.LeagueRepository;
|
||||
import com.totopia.server.modules.game.repository.SportsRepository;
|
||||
import com.totopia.server.modules.game.type.SportsName;
|
||||
import com.totopia.server.modules.user.entity.GradeEntity;
|
||||
|
@ -46,79 +48,359 @@ public class DbInitializer implements CommandLineRunner {
|
|||
@Autowired
|
||||
SportsRepository sportsRepository;
|
||||
|
||||
@Autowired
|
||||
LeagueRepository leagueRepository;
|
||||
|
||||
@Override
|
||||
public void run(String... strings) throws Exception {
|
||||
if (0 == roleRepository.count()) {
|
||||
RoleEntity role;
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_USER).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_TEAM).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_AGENCY).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_ADMIN).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_SUPER_ADMIN).build();
|
||||
roleRepository.save(role);
|
||||
this.initDbRole();
|
||||
}
|
||||
|
||||
if (0 == gradeRepository.count()) {
|
||||
GradeEntity grade;
|
||||
grade = GradeEntity.builder().name(GradeName.BAD_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.NORMAL_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.REGULAR_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.VIP_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.PLATINUM_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
this.initDbGrade();
|
||||
}
|
||||
|
||||
if (0 == sportsRepository.count()) {
|
||||
SportsEntity sportsEntity;
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.SOCCER).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.BASEBALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.BASKET_BALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.E_SPORTS).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.HAND_BALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.TABLE_TENIS).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.VALLEY_BALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.TENNIS).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
|
||||
this.initDbSports();
|
||||
}
|
||||
if (0 == userRepository.count()) {
|
||||
UserEntity user;
|
||||
user = UserEntity.builder().username("admin").password(passwordEncoder.encode("admin")).nickname("admin")
|
||||
.email("admin@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 1)).build())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
|
||||
userRepository.save(user);
|
||||
user = UserEntity.builder().username("test1").password(passwordEncoder.encode("qwer5795")).nickname("test1")
|
||||
.email("test1@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 2)).build())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
userRepository.save(user);
|
||||
|
||||
user = UserEntity.builder().username("test2").password(passwordEncoder.encode("qwer5795")).nickname("test2")
|
||||
.email("test1@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 2)).build())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
|
||||
userRepository.save(user);
|
||||
this.initDbUsers();
|
||||
}
|
||||
|
||||
if (0 == leagueRepository.count()) {
|
||||
this.initDbLeague();
|
||||
}
|
||||
log.debug("-- Database has been initialized");
|
||||
}
|
||||
|
||||
private void initDbRole() {
|
||||
RoleEntity role;
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_USER).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_TEAM).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_AGENCY).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_ADMIN).build();
|
||||
roleRepository.save(role);
|
||||
role = RoleEntity.builder().name(RoleName.ROLE_SUPER_ADMIN).build();
|
||||
roleRepository.save(role);
|
||||
}
|
||||
|
||||
private void initDbUsers() {
|
||||
UserEntity user;
|
||||
user = UserEntity.builder().username("admin").password(passwordEncoder.encode("admin")).nickname("admin")
|
||||
.email("admin@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 1)).build())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
|
||||
userRepository.save(user);
|
||||
user = UserEntity.builder().username("test1").password(passwordEncoder.encode("qwer5795")).nickname("test1")
|
||||
.email("test1@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 2)).build())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
userRepository.save(user);
|
||||
|
||||
user = UserEntity.builder().username("test2").password(passwordEncoder.encode("qwer5795")).nickname("test2")
|
||||
.email("test1@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 2)).build())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
|
||||
userRepository.save(user);
|
||||
}
|
||||
private void initDbGrade() {
|
||||
GradeEntity grade;
|
||||
grade = GradeEntity.builder().name(GradeName.BAD_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.NORMAL_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.REGULAR_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.VIP_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
grade = GradeEntity.builder().name(GradeName.PLATINUM_USER).build();
|
||||
gradeRepository.save(grade);
|
||||
}
|
||||
|
||||
private void initDbSports() {
|
||||
SportsEntity sportsEntity;
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.SOCCER).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.BASEBALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.BASKET_BALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.E_SPORTS).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.HAND_BALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.TABLE_TENIS).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.VALLEY_BALL).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
sportsEntity = SportsEntity.builder().name(SportsName.TENNIS).build();
|
||||
sportsRepository.save(sportsEntity);
|
||||
}
|
||||
private void initDbLeague() {
|
||||
LeagueEntity leagueEntity;
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Bundesliga I")
|
||||
.kor_name("분데스리가")
|
||||
.sevenMName("GER BI")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Bundesliga II")
|
||||
.kor_name("분데스리가 2")
|
||||
.sevenMName("GER B2")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany 3.Liga")
|
||||
.kor_name("3.리가")
|
||||
.sevenMName("GER L3")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga West")
|
||||
.kor_name("레기오날리가 웨스트")
|
||||
.sevenMName("GER RL W")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga North")
|
||||
.kor_name("레기오날리가 노스")
|
||||
.sevenMName("GER RL N")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga North East")
|
||||
.kor_name("레기오날리가 노스 이스트")
|
||||
.sevenMName("GER RL NE")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Rheinland-Pfalz/Saar")
|
||||
.kor_name("오벨리가 Rheinland-Pfalz/Saar")
|
||||
.sevenMName("GER OL R")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga Bayern")
|
||||
.kor_name("레기오날리가 바이에른")
|
||||
.sevenMName("GER RL B")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Hamburg")
|
||||
.kor_name("오벨리가 함부르크")
|
||||
.sevenMName("GER OL H")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Bayern North")
|
||||
.kor_name("오벨리가 바이에른 노스")
|
||||
.sevenMName("GER OL BN")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Baden-Wuerttemberg")
|
||||
.kor_name("오벨리가 Baden-Wuerttemberg")
|
||||
.sevenMName("GER OL BW")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Westfalen")
|
||||
.kor_name("오벨리가 Westfalen")
|
||||
.sevenMName("GER OL W")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga NOFV Sud")
|
||||
.kor_name("오벨리가 NOFV Sud")
|
||||
.sevenMName("GER OL NS")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Bundesliga Women")
|
||||
.kor_name("우먼 분데스리가")
|
||||
.sevenMName("Germany BW")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("Barclays Premier League")
|
||||
.kor_name("프리미어 리그")
|
||||
.sevenMName("Barclays PL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England League 2")
|
||||
.kor_name("리그 2")
|
||||
.sevenMName("UK L2")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England National League")
|
||||
.kor_name("내셔널 리그")
|
||||
.sevenMName("UK NL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England National League North")
|
||||
.kor_name("내셔널 리그 노스")
|
||||
.sevenMName("UK NLN")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England National League South")
|
||||
.kor_name("내셔널 리그 사우스")
|
||||
.sevenMName("UK NLS")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Isthmian Premier Division")
|
||||
.kor_name("이스미안 프리미어 디비전")
|
||||
.sevenMName("Isthmian PD")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Southern Premier League South")
|
||||
.kor_name("사우던 프리미어 리그 사우스")
|
||||
.sevenMName("England SPL S")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Southern Premier League Central")
|
||||
.kor_name("사우던 프리미어 리그 센트럴")
|
||||
.sevenMName("England SPL C")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Southern League Division One")
|
||||
.kor_name("사우던 리그 디비전 1")
|
||||
.sevenMName("UK SLD1")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England U23 Development League")
|
||||
.kor_name("유스 U23 디벨럽먼트 리그")
|
||||
.sevenMName("England U23 DL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("Lancashire Senior Cup")
|
||||
.kor_name("랭커셔 시니어 컵")
|
||||
.sevenMName("UK LS Cup")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England FA WSL")
|
||||
.kor_name("우먼 FA 슈퍼리그")
|
||||
.sevenMName("FA WSL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,286 +0,0 @@
|
|||
package com.totopia.server.init;
|
||||
|
||||
import com.totopia.server.modules.game.entity.LeagueEntity;
|
||||
import com.totopia.server.modules.game.entity.SportsEntity;
|
||||
import com.totopia.server.modules.game.repository.LeagueRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(name = "app.db-init", havingValue = "true")
|
||||
@Slf4j
|
||||
public class LeagueDbInitializer implements CommandLineRunner {
|
||||
@Autowired
|
||||
LeagueRepository leagueRepository;
|
||||
|
||||
@Override
|
||||
public void run(String... strings) throws Exception {
|
||||
if (0 == leagueRepository.count()) {
|
||||
LeagueEntity leagueEntity;
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Bundesliga I")
|
||||
.kor_name("분데스리가")
|
||||
.sevenMName("GER BI")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Bundesliga II")
|
||||
.kor_name("분데스리가 2")
|
||||
.sevenMName("GER B2")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany 3.Liga")
|
||||
.kor_name("3.리가")
|
||||
.sevenMName("GER L3")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga West")
|
||||
.kor_name("레기오날리가 웨스트")
|
||||
.sevenMName("GER RL W")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga North")
|
||||
.kor_name("레기오날리가 노스")
|
||||
.sevenMName("GER RL N")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga North East")
|
||||
.kor_name("레기오날리가 노스 이스트")
|
||||
.sevenMName("GER RL NE")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Rheinland-Pfalz/Saar")
|
||||
.kor_name("오벨리가 Rheinland-Pfalz/Saar")
|
||||
.sevenMName("GER OL R")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Regionalliga Bayern")
|
||||
.kor_name("레기오날리가 바이에른")
|
||||
.sevenMName("GER RL B")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Hamburg")
|
||||
.kor_name("오벨리가 함부르크")
|
||||
.sevenMName("GER OL H")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Bayern North")
|
||||
.kor_name("오벨리가 바이에른 노스")
|
||||
.sevenMName("GER OL BN")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Baden-Wuerttemberg")
|
||||
.kor_name("오벨리가 Baden-Wuerttemberg")
|
||||
.sevenMName("GER OL BW")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga Westfalen")
|
||||
.kor_name("오벨리가 Westfalen")
|
||||
.sevenMName("GER OL W")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Oberliga NOFV Sud")
|
||||
.kor_name("오벨리가 NOFV Sud")
|
||||
.sevenMName("GER OL NS")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("Germany")
|
||||
.korCountry("독일")
|
||||
.eng_name("Germany Bundesliga Women")
|
||||
.kor_name("우먼 분데스리가")
|
||||
.sevenMName("Germany BW")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("Barclays Premier League")
|
||||
.kor_name("프리미어 리그")
|
||||
.sevenMName("Barclays PL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England League 2")
|
||||
.kor_name("리그 2")
|
||||
.sevenMName("UK L2")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England National League")
|
||||
.kor_name("내셔널 리그")
|
||||
.sevenMName("UK NL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England National League North")
|
||||
.kor_name("내셔널 리그 노스")
|
||||
.sevenMName("UK NLN")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England National League South")
|
||||
.kor_name("내셔널 리그 사우스")
|
||||
.sevenMName("UK NLS")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Isthmian Premier Division")
|
||||
.kor_name("이스미안 프리미어 디비전")
|
||||
.sevenMName("Isthmian PD")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Southern Premier League South")
|
||||
.kor_name("사우던 프리미어 리그 사우스")
|
||||
.sevenMName("England SPL S")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Southern Premier League Central")
|
||||
.kor_name("사우던 프리미어 리그 센트럴")
|
||||
.sevenMName("England SPL C")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England Southern League Division One")
|
||||
.kor_name("사우던 리그 디비전 1")
|
||||
.sevenMName("UK SLD1")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England U23 Development League")
|
||||
.kor_name("유스 U23 디벨럽먼트 리그")
|
||||
.sevenMName("England U23 DL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("Lancashire Senior Cup")
|
||||
.kor_name("랭커셔 시니어 컵")
|
||||
.sevenMName("UK LS Cup")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
|
||||
leagueEntity = LeagueEntity.builder()
|
||||
.engCountry("England")
|
||||
.korCountry("잉글랜드")
|
||||
.eng_name("England FA WSL")
|
||||
.kor_name("우먼 FA 슈퍼리그")
|
||||
.sevenMName("FA WSL")
|
||||
.sportsEntities(Stream.of(SportsEntity.builder().id(Short.valueOf((short) 1)).build()).collect(Collectors.toCollection(HashSet::new)))
|
||||
.build();
|
||||
this.leagueRepository.save(leagueEntity);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user