리그 클래스 추가 및 테스트 코드
This commit is contained in:
parent
dcf2a0295c
commit
3873ef7754
|
@ -1,6 +1,9 @@
|
||||||
package com.totopia.server.init;
|
package com.totopia.server.init;
|
||||||
|
|
||||||
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
||||||
|
import com.totopia.server.modules.game.entity.SportsEntity;
|
||||||
|
import com.totopia.server.modules.game.repository.SportsRepository;
|
||||||
|
import com.totopia.server.modules.game.type.SportsName;
|
||||||
import com.totopia.server.modules.user.entity.GradeEntity;
|
import com.totopia.server.modules.user.entity.GradeEntity;
|
||||||
import com.totopia.server.modules.user.entity.RoleEntity;
|
import com.totopia.server.modules.user.entity.RoleEntity;
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
|
@ -40,6 +43,10 @@ public class DbInitializer implements CommandLineRunner {
|
||||||
@Autowired
|
@Autowired
|
||||||
GradeRepository gradeRepository;
|
GradeRepository gradeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SportsRepository sportsRepository;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... strings) throws Exception {
|
public void run(String... strings) throws Exception {
|
||||||
if (0 == roleRepository.count()) {
|
if (0 == roleRepository.count()) {
|
||||||
|
@ -70,6 +77,26 @@ public class DbInitializer implements CommandLineRunner {
|
||||||
gradeRepository.save(grade);
|
gradeRepository.save(grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
if (0 == userRepository.count()) {
|
if (0 == userRepository.count()) {
|
||||||
UserEntity user;
|
UserEntity user;
|
||||||
user = UserEntity.builder().username("admin").password(passwordEncoder.encode("admin")).nickname("admin")
|
user = UserEntity.builder().username("admin").password(passwordEncoder.encode("admin")).nickname("admin")
|
||||||
|
|
286
src/main/java/com/totopia/server/init/LeagueDbInitializer.java
Normal file
286
src/main/java/com/totopia/server/init/LeagueDbInitializer.java
Normal file
|
@ -0,0 +1,286 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.totopia.server.modules.game.entity;
|
||||||
|
|
||||||
|
import com.totopia.server.commons.data.entity.DateAuditEntity;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "league")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Builder
|
||||||
|
public class LeagueEntity extends DateAuditEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generator = "league_generator")
|
||||||
|
@SequenceGenerator(name = "league_generator", sequenceName = "league_sequence", initialValue = 1)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "eng_name", nullable = false, length = 200)
|
||||||
|
private String eng_name;
|
||||||
|
|
||||||
|
@Column(name = "kor_name", nullable = true, length = 200)
|
||||||
|
private String kor_name;
|
||||||
|
|
||||||
|
@Column(name = "seven_m_name", nullable = true, length = 50)
|
||||||
|
private String sevenMName;
|
||||||
|
|
||||||
|
@Column(name = "eng_country", nullable = true, length = 100)
|
||||||
|
private String engCountry;
|
||||||
|
|
||||||
|
@Column(name = "kor_country", nullable = true, length = 100)
|
||||||
|
private String korCountry;
|
||||||
|
|
||||||
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
@JoinTable(name = "league_sports", joinColumns = @JoinColumn(name = "league_id"), inverseJoinColumns = @JoinColumn(name = "sports_id"))
|
||||||
|
private Set<SportsEntity> sportsEntities;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.totopia.server.modules.game.entity;
|
||||||
|
|
||||||
|
import com.totopia.server.commons.data.entity.DateAuditEntity;
|
||||||
|
import com.totopia.server.modules.game.type.SportsName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "sports")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class SportsEntity extends DateAuditEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generator = "sports_generator")
|
||||||
|
@SequenceGenerator(name = "sports_generator", sequenceName = "sports_sequence", initialValue = 1)
|
||||||
|
private Short id;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "name", length = 60)
|
||||||
|
private SportsName name;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.totopia.server.modules.game.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.modules.game.entity.LeagueEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface LeagueRepository extends JpaRepository<LeagueEntity, Long> {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.totopia.server.modules.game.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.modules.game.entity.SportsEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface SportsRepository extends JpaRepository<SportsEntity, Short> {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.totopia.server.modules.game.type;
|
||||||
|
|
||||||
|
public enum SportsName {
|
||||||
|
SOCCER,
|
||||||
|
BASEBALL,
|
||||||
|
BASKET_BALL,
|
||||||
|
E_SPORTS,
|
||||||
|
TENNIS,
|
||||||
|
TABLE_TENIS,
|
||||||
|
VALLEY_BALL,
|
||||||
|
HAND_BALL
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.totopia.server.modules.game.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.modules.game.entity.LeagueEntity;
|
||||||
|
import com.totopia.server.modules.game.entity.SportsEntity;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
//@Ignore
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class LeagueRepositoryTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
LeagueRepository leagueRepository;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInsert() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLeagueByName() {
|
||||||
|
|
||||||
|
LeagueEntity leagueEntity = this.leagueRepository.findById(1L).orElseThrow(null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.totopia.server.modules.game.repository;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SportsRepositoryTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user