Skip to content

Commit

Permalink
[REFACTOR] PresentationInitializer Team 생성 로직 추가 (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlajm1203 authored Oct 3, 2024
1 parent 58a613d commit e4ce43c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eeos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ group = 'com.econovation'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '11'
sourceCompatibility = '17'
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void run(ApplicationArguments args) throws Exception {

Set<Long> target = programs.stream().filter(programId -> !presentations.contains(programId)).collect(Collectors.toSet());

Long defaultTeamId = teamRepository.findById(0L).orElseThrow().getId();
Long defaultTeamId = getTempTeam().getId();

Set<PresentationEntity> entities = target.stream().map(targetId -> PresentationEntity.builder().teamId(defaultTeamId).programId(targetId).build()).collect(Collectors.toSet());

Expand All @@ -49,6 +50,19 @@ private List<ProgramEntity> 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<PresentationEntity> getPresentations(){
return presentationRepository.findAll();
}
Expand Down

0 comments on commit e4ce43c

Please sign in to comment.