-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from JNU-econovation/feature/BE-87
[REFACTOR] MongoAnswer state 필드 null 처리 및 PATCH 응답 형식 JSON으로 변경
- Loading branch information
Showing
10 changed files
with
95 additions
and
23 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
server/Recruit-Api/src/main/java/com/econovation/recruit/utils/ApplicantStateCheck.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,47 @@ | ||
package com.econovation.recruit.utils; | ||
|
||
import com.econovation.recruit.api.applicant.usecase.ApplicantCommandUseCase; | ||
import com.econovation.recruit.api.applicant.usecase.ApplicantQueryUseCase; | ||
import com.econovation.recruitdomain.domains.applicant.adaptor.AnswerAdaptor; | ||
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer; | ||
import io.vavr.concurrent.Future; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.ApplicationArguments; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ApplicantStateCheck implements ApplicationRunner { | ||
|
||
private final AnswerAdaptor answerAdaptor; | ||
|
||
@PostConstruct | ||
public void init() throws IOException, SQLException { | ||
// init.sql 파일을 읽어와서 실행합니다. | ||
log.info("MongoDB Applicant State 체크를 시작합니다."); | ||
} | ||
|
||
@Override | ||
public void run(ApplicationArguments args) throws Exception { | ||
try { | ||
List<MongoAnswer> answers = answerAdaptor.findAll().stream().filter(answer -> answer.getApplicantState()==null).toList(); | ||
answers.forEach(MongoAnswer::stateEmptyCheckAndInit); | ||
answerAdaptor.saveAll(answers); | ||
log.info("MongoDB Applicant State Check를 완료했습니다."); | ||
} catch (Exception e){ | ||
e.printStackTrace(); | ||
log.error("MongoDB Applicant State Check를 실패했습니다."); | ||
} | ||
} | ||
} |
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