diff --git a/eeos/build.gradle b/eeos/build.gradle index 2ae47c6a..627875f0 100644 --- a/eeos/build.gradle +++ b/eeos/build.gradle @@ -33,7 +33,7 @@ group = 'com.econovation' version = '0.0.1-SNAPSHOT' java { - sourceCompatibility = '11' + sourceCompatibility = '17' } configurations { diff --git a/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java b/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java index c26e34cf..8b532f04 100644 --- a/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java +++ b/eeos/src/main/java/com/blackcompany/eeos/target/application/util/PresentationInitializer.java @@ -4,6 +4,7 @@ import com.blackcompany.eeos.program.persistence.ProgramRepository; import com.blackcompany.eeos.target.persistence.PresentationEntity; import com.blackcompany.eeos.target.persistence.PresentationRepository; +import com.blackcompany.eeos.team.application.exception.NotFoundTeamException; import com.blackcompany.eeos.team.persistence.TeamEntity; import com.blackcompany.eeos.team.persistence.TeamRepository; import lombok.RequiredArgsConstructor; @@ -37,7 +38,7 @@ public void run(ApplicationArguments args) throws Exception { Set target = programs.stream().filter(programId -> !presentations.contains(programId)).collect(Collectors.toSet()); - Long defaultTeamId = teamRepository.findById(0L).orElseThrow().getId(); + Long defaultTeamId = getTempTeam().getId(); Set entities = target.stream().map(targetId -> PresentationEntity.builder().teamId(defaultTeamId).programId(targetId).build()).collect(Collectors.toSet()); @@ -49,6 +50,19 @@ private List getPrograms(){ return programRepository.findAll(); } + private TeamEntity getTempTeam(){ + try { + return teamRepository.findTeamEntityByName("임시 활동 팀").stream().findFirst().orElseThrow(()->new NotFoundTeamException(0L)); + } catch (NotFoundTeamException e){ + return createTempTeam(); + } + } + + private TeamEntity createTempTeam(){ + TeamEntity newTeam = TeamEntity.builder().name("임시 활동 팀").status(false).build(); + return teamRepository.save(newTeam); + } + private List getPresentations(){ return presentationRepository.findAll(); }