-
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.
Browse files
Browse the repository at this point in the history
개발 디버깅용 테스트 데이터 추가 및 모집 공고 마감기한 검증 로직 수정
- Loading branch information
Showing
12 changed files
with
201 additions
and
68 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
src/main/java/com/server/crews/global/config/DatabaseInitializer.java
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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.server.crews.global.config; | ||
|
||
import com.server.crews.applicant.domain.Application; | ||
import com.server.crews.applicant.domain.NarrativeAnswer; | ||
import com.server.crews.applicant.domain.SelectiveAnswer; | ||
import com.server.crews.applicant.repository.ApplicationRepository; | ||
import com.server.crews.auth.domain.Administrator; | ||
import com.server.crews.auth.domain.Applicant; | ||
import com.server.crews.auth.repository.AdministratorRepository; | ||
import com.server.crews.auth.repository.ApplicantRepository; | ||
import com.server.crews.recruitment.domain.Choice; | ||
import com.server.crews.recruitment.domain.NarrativeQuestion; | ||
import com.server.crews.recruitment.domain.Recruitment; | ||
import com.server.crews.recruitment.domain.Section; | ||
import com.server.crews.recruitment.domain.SelectiveQuestion; | ||
import com.server.crews.recruitment.repository.RecruitmentRepository; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.ApplicationArguments; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Profile(value = "!prod") | ||
@Component | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class DatabaseInitializer implements ApplicationRunner { | ||
private final PasswordEncoder passwordEncoder; | ||
private final AdministratorRepository administratorRepository; | ||
private final RecruitmentRepository recruitmentRepository; | ||
private final ApplicantRepository applicantRepository; | ||
private final ApplicationRepository applicationRepository; | ||
|
||
@Override | ||
public void run(ApplicationArguments args) { | ||
Administrator administrator = new Administrator("admin", passwordEncoder.encode("12341234!")); | ||
administratorRepository.save(administrator); | ||
|
||
NarrativeQuestion introductionQuestion = new NarrativeQuestion(null, "자기소개해주세요", true, 1, 500); | ||
List<Choice> personalityChoices = List.of(new Choice(null, "성실함"), new Choice(null, "밝음"), | ||
new Choice(null, "꼼꼼함")); | ||
SelectiveQuestion personalityQuestion = new SelectiveQuestion(null, personalityChoices, "장점을 골라주세요", true, 2, 1, | ||
1); | ||
Section commonSection = new Section(null, "공통", "웹 어플리케이션 서버 개발 파트", List.of(introductionQuestion), | ||
List.of(personalityQuestion)); | ||
|
||
NarrativeQuestion backendNarrativeQuestion = new NarrativeQuestion(null, "백엔드 파트와 관련된 활동 하나를 서술해주세요.", true, 1, | ||
600); | ||
List<Choice> backendStackChoices = List.of(new Choice(null, "Django, Python"), | ||
new Choice(null, "Springboot, Java")); | ||
SelectiveQuestion backendStackQuestion = new SelectiveQuestion(null, backendStackChoices, | ||
"멋사 프로젝트에서 사용하고 싶은 스택을 골라주세요", true, 2, 1, 2); | ||
Section backendSection = new Section(null, "백엔드", "웹 어플리케이션 서버 개발 파트", List.of(backendNarrativeQuestion), | ||
List.of(backendStackQuestion)); | ||
|
||
NarrativeQuestion frontendNarrativeQuestion = new NarrativeQuestion(null, "프론트엔드 파트와 관련된 활동 하나를 서술해주세요.", true, | ||
1, 600); | ||
Section frontendSection = new Section(null, "프론트엔드", "웹 클라이언트 사이드 개발 파트", List.of(frontendNarrativeQuestion), | ||
List.of()); | ||
|
||
Recruitment recruitment = new Recruitment(null, "test-code", "멋쟁이 사자처럼 99기 아기사자 모집", | ||
"멋쟁이 사자처럼 서강대에서 99기 아기사자를 모집합니다!", LocalDateTime.of(2024, 9, 1, 2, 0), administrator, | ||
List.of(commonSection, backendSection, frontendSection)); | ||
recruitment.close(); | ||
recruitmentRepository.save(recruitment); | ||
|
||
Applicant kh = new Applicant("[email protected]", passwordEncoder.encode("test-password")); | ||
Applicant lkh = new Applicant("[email protected]", passwordEncoder.encode("test-password")); | ||
applicantRepository.saveAll(List.of(kh, lkh)); | ||
|
||
NarrativeAnswer skhIntroductionAnswer = new NarrativeAnswer(null, introductionQuestion, "안녕하세요"); | ||
SelectiveAnswer skhPersonalityAnswer = new SelectiveAnswer(null, personalityChoices.get(0), | ||
personalityQuestion); | ||
NarrativeAnswer skhBackendNarrativeAnswer = new NarrativeAnswer(null, backendNarrativeQuestion, | ||
"크루즈 프로젝트 서버 개발을 맡았습니다."); | ||
SelectiveAnswer skhBackendStackAnswer = new SelectiveAnswer(null, backendStackChoices.get(1), | ||
backendStackQuestion); | ||
Application skhApplication = new Application(null, recruitment, kh, "202011414", "컴퓨터공학", "송경호", | ||
List.of(skhIntroductionAnswer, skhBackendNarrativeAnswer), | ||
List.of(skhPersonalityAnswer, skhBackendStackAnswer)); | ||
applicationRepository.save(skhApplication); | ||
|
||
NarrativeAnswer lkhIntroductionAnswer = new NarrativeAnswer(null, introductionQuestion, "반갑습니다"); | ||
SelectiveAnswer lkhPersonalityAnswer = new SelectiveAnswer(null, personalityChoices.get(1), | ||
personalityQuestion); | ||
NarrativeAnswer lkhFrontendNarrativeAnswer = new NarrativeAnswer(null, frontendNarrativeQuestion, | ||
"크루즈 프로젝트 프론트 개발을 맡았습니다."); | ||
Application lkhApplication = new Application(null, recruitment, lkh, "202013232", "컴퓨터공학", "이규호", | ||
List.of(lkhIntroductionAnswer, lkhFrontendNarrativeAnswer), List.of(lkhPersonalityAnswer)); | ||
applicationRepository.save(lkhApplication); | ||
} | ||
} |
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
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.