-
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 #233 from rlajm1203/feature/BE-87
[BE-87] 지원자 합/불 상태 필드 추가 및 지원서 상태 변경 API 추가
- Loading branch information
Showing
19 changed files
with
375 additions
and
8 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
38 changes: 38 additions & 0 deletions
38
...va/com/econovation/recruit/api/applicant/aggregate/ApplicantStateUpdateEventListener.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,38 @@ | ||
package com.econovation.recruit.api.applicant.aggregate; | ||
|
||
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer; | ||
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswerAdaptor; | ||
import com.econovation.recruitdomain.domains.applicant.event.aggregateevent.ApplicantStateUpdateEvent; | ||
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantStateEvents; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.axonframework.eventhandling.EventHandler; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ApplicantStateUpdateEventListener { | ||
|
||
private final MongoAnswerAdaptor answerAdaptor; | ||
|
||
@EventHandler | ||
@Transactional | ||
public String handle(ApplicantStateUpdateEvent event){ | ||
MongoAnswer answer = answerAdaptor.findById(event.getId()).get(); | ||
ApplicantStateEvents command = ApplicantStateEvents.find(event.getAfterState()); | ||
|
||
switch (command) { | ||
case PASS: | ||
answer.pass(); | ||
break; | ||
case NON_PASS: | ||
answer.nonPass(); | ||
break; | ||
} | ||
|
||
answerAdaptor.save(answer); | ||
return answer.getApplicantState().getPassState(); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
.../main/java/com/econovation/recruit/api/applicant/command/UpdateApplicantStateCommand.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,16 @@ | ||
package com.econovation.recruit.api.applicant.command; | ||
|
||
import lombok.*; | ||
import org.axonframework.modelling.command.TargetAggregateIdentifier; | ||
|
||
@AllArgsConstructor | ||
@ToString | ||
@Data | ||
@NoArgsConstructor | ||
@Getter | ||
public class UpdateApplicantStateCommand { | ||
|
||
@TargetAggregateIdentifier private String id; | ||
private String afterState; | ||
|
||
} |
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
44 changes: 44 additions & 0 deletions
44
.../java/com/econovation/recruit/api/applicant/handler/ApplicantStateUpdateEventHandler.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,44 @@ | ||
package com.econovation.recruit.api.applicant.handler; | ||
|
||
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer; | ||
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswerAdaptor; | ||
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantRegisterEvent; | ||
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantStateEvents; | ||
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantStateModifyEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ApplicantStateUpdateEventHandler { | ||
|
||
private final MongoAnswerAdaptor answerAdaptor; | ||
|
||
// @Async | ||
// @TransactionalEventListener( | ||
// classes = ApplicantRegisterEvent.class, | ||
// phase = TransactionPhase.AFTER_COMMIT) | ||
// @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public String handle(ApplicantStateModifyEvent event){ | ||
MongoAnswer answer = answerAdaptor.findById(event.getApplicantId()).get(); | ||
ApplicantStateEvents command = event.getEvent(); | ||
|
||
switch (command) { | ||
case PASS: | ||
answer.pass(); | ||
break; | ||
case NON_PASS: | ||
answer.nonPass(); | ||
break; | ||
} | ||
|
||
answerAdaptor.save(answer); | ||
return answer.getApplicantState().getPassState(); | ||
} | ||
|
||
} |
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
52 changes: 52 additions & 0 deletions
52
.../java/com/econovation/recruit/api/applicant/state/config/ApplicantStateMachineConfig.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,52 @@ | ||
package com.econovation.recruit.api.applicant.state.config; | ||
|
||
import com.econovation.recruitdomain.domains.applicant.domain.PassStates; | ||
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantStateEvents; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.statemachine.config.EnableStateMachine; | ||
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter; | ||
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; | ||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; | ||
|
||
@Configuration | ||
@EnableStateMachine | ||
public class ApplicantStateMachineConfig extends EnumStateMachineConfigurerAdapter<PassStates, ApplicantStateEvents> { | ||
|
||
|
||
@Override | ||
public void configure(StateMachineStateConfigurer<PassStates, ApplicantStateEvents> states) throws Exception { | ||
states | ||
.withStates() | ||
.initial(PassStates.NONPASSED) | ||
.state(PassStates.FIRSTPASSED) | ||
.end(PassStates.FINALPASSED); | ||
} | ||
|
||
/** | ||
* | ||
* @param transitions | ||
* @throws Exception | ||
* | ||
* States | ||
* NONPASSED : 불합격 | ||
* FIRSTPASSED : 1차 합격 | ||
* FINALPASSED : 최종 합격 | ||
* | ||
* Events | ||
* NON_PASS : 불합격 | ||
* PASS : 합격 (다음 단계로 전환) | ||
*/ | ||
|
||
@Override | ||
public void configure(StateMachineTransitionConfigurer<PassStates, ApplicantStateEvents> transitions) throws Exception { | ||
transitions | ||
.withExternal() | ||
.source(PassStates.NONPASSED).target(PassStates.FIRSTPASSED).event(ApplicantStateEvents.PASS) | ||
.and() | ||
.withExternal() | ||
.source(PassStates.FIRSTPASSED).target(PassStates.FINALPASSED).event(ApplicantStateEvents.PASS) | ||
.and() | ||
.withExternal() | ||
.source(PassStates.FIRSTPASSED).target(PassStates.NONPASSED).event(ApplicantStateEvents.NON_PASS); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...i/src/main/java/com/econovation/recruit/api/applicant/state/support/ApplicantManager.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,14 @@ | ||
package com.econovation.recruit.api.applicant.state.support; | ||
|
||
import com.econovation.recruitdomain.domains.applicant.support.ApplicantStateManger; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ApplicantManager implements ApplicantStateManger { | ||
|
||
@Override | ||
public void update(String applicantId, String afterState) { | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
.../src/main/java/com/econovation/recruitdomain/domains/applicant/domain/ApplicantState.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,23 @@ | ||
package com.econovation.recruitdomain.domains.applicant.domain; | ||
|
||
public class ApplicantState { | ||
|
||
private PassStates passState; | ||
|
||
public ApplicantState(){ | ||
this.passState = PassStates.NONPASSED; // 초기 상태 | ||
} | ||
|
||
public void nextPassState(){ | ||
this.passState = this.passState.next(); | ||
} | ||
|
||
public void prevPassState(){ | ||
this.passState = this.passState.prev(); | ||
} | ||
|
||
public String getPassState(){ | ||
return this.passState.getStatus(); | ||
} | ||
|
||
} |
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.