Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE-96] 라벨 목록은 TF이상 권한인 면접관만 뜨도록 수정 #273

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import com.econovation.recruit.api.applicant.command.UpdateApplicantStateCommand;
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer;
import com.econovation.recruitdomain.domains.applicant.event.aggregateevent.AnswerCreatedEvent;
import java.util.Map;

import com.econovation.recruitdomain.domains.applicant.event.aggregateevent.ApplicantStateUpdateEvent;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -35,7 +34,7 @@ public AnswerAggregate(CreateAnswerCommand command) {
}

@CommandHandler
public AnswerAggregate(UpdateApplicantStateCommand command){
public AnswerAggregate(UpdateApplicantStateCommand command) {
apply(new ApplicantStateUpdateEvent(command.getId(), command.getAfterState()));
}

Expand All @@ -48,7 +47,7 @@ public void on(AnswerCreatedEvent event) {
}

@EventSourcingHandler
public void on(ApplicantStateUpdateEvent event){
public void on(ApplicantStateUpdateEvent event) {
this.id = event.getId();
log.info("ApplicantID : " + event.getId());
log.info("상태 변경 : " + event.getAfterState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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;
Expand All @@ -20,7 +19,7 @@ public class ApplicantStateUpdateEventListener {

@EventHandler
@Transactional
public String handle(ApplicantStateUpdateEvent event){
public String handle(ApplicantStateUpdateEvent event) {
MongoAnswer answer = answerAdaptor.findById(event.getId()).get();
ApplicantStateEvents command = ApplicantStateEvents.find(event.getAfterState());

Expand All @@ -36,5 +35,4 @@ public String handle(ApplicantStateUpdateEvent event){
answerAdaptor.save(answer);
return answer.getApplicantStateOrDefault().getPassState();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ public class UpdateApplicantStateCommand {

@TargetAggregateIdentifier private String id;
private String afterState;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.econovation.recruit.api.applicant.controller;

import static com.econovation.recruitcommon.consts.RecruitStatic.APPLICANT_SUCCESS_REGISTER_MESSAGE;
import static com.econovation.recruitcommon.consts.RecruitStatic.PASS_STATE_KEY;

import com.econovation.recruit.api.applicant.command.CreateAnswerCommand;
import com.econovation.recruit.api.applicant.docs.CreateApplicantExceptionDocs;
import com.econovation.recruit.api.applicant.dto.AnswersResponseDto;
Expand All @@ -18,6 +21,11 @@
import com.econovation.recruitinfrastructure.apache.CommonsEmailSender;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.axonframework.commandhandling.gateway.CommandGateway;
Expand All @@ -27,15 +35,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static com.econovation.recruitcommon.consts.RecruitStatic.APPLICANT_SUCCESS_REGISTER_MESSAGE;
import static com.econovation.recruitcommon.consts.RecruitStatic.PASS_STATE_KEY;

@RestController
@RequestMapping("/api/v1")
@RequiredArgsConstructor
Expand Down Expand Up @@ -150,20 +149,22 @@ public ResponseEntity sendEmail(@RequestBody EmailSendDto emailSendDto) {

@Operation(summary = "지원자의 합/불 상태를 변경합니다.")
@PatchMapping("/applicants/{applicant-id}/state")
public ResponseEntity<Map<String, String>> updateStatus(@PathVariable("applicant-id") String applicantId,
@RequestParam("afterState") String afterState){
// commandGateway.send(new UpdateApplicantStateCommand(applicantId, afterState));
public ResponseEntity<Map<String, String>> updateStatus(
@PathVariable("applicant-id") String applicantId,
@RequestParam("afterState") String afterState) {
// commandGateway.send(new UpdateApplicantStateCommand(applicantId, afterState));
String state = applicantCommandUseCase.execute(applicantId, afterState);
Map<String, String> response = new HashMap<>();
response.put(PASS_STATE_KEY, state);
return new ResponseEntity(response,HttpStatus.OK);
return new ResponseEntity(response, HttpStatus.OK);
}

@Operation(summary = "지원서의 합/불 상태를 조회합니다. (합/불 관리자 페이지 전용)")
@GetMapping("year/{year}/applicants/pass-state")
public ResponseEntity<List<GetApplicantsStatusResponse>> getApplicantsStatus(@PathVariable("year") Integer year,
@RequestParam("order") String sortType) {
List<GetApplicantsStatusResponse> result = applicantQueryUseCase.getApplicantsStatus(year, sortType);
public ResponseEntity<List<GetApplicantsStatusResponse>> getApplicantsStatus(
@PathVariable("year") Integer year, @RequestParam("order") String sortType) {
List<GetApplicantsStatusResponse> result =
applicantQueryUseCase.getApplicantsStatus(year, sortType);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.econovation.recruit.api.applicant.dto;

import static com.econovation.recruitcommon.consts.RecruitStatic.PASS_STATE_KEY;

import com.econovation.recruitdomain.domains.applicant.domain.state.ApplicantState;
import com.econovation.recruitdomain.domains.applicant.exception.ApplicantWrongStateException;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.Map;

import static com.econovation.recruitcommon.consts.RecruitStatic.PASS_STATE_KEY;

@Data
@AllArgsConstructor
@Builder
Expand All @@ -36,4 +35,4 @@ public static GetApplicantsStatusResponse of(Map<String, Object> result) {
}
throw ApplicantWrongStateException.wrongStatusException;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class ApplicantStateUpdateEventHandler {
private final MongoAnswerAdaptor answerAdaptor;
private final PeriodCalculator periodCalculator;

// @Async
// @TransactionalEventListener(
// classes = ApplicantRegisterEvent.class,
// phase = TransactionPhase.AFTER_COMMIT)
// @Transactional(propagation = Propagation.REQUIRES_NEW)
public String handle(ApplicantStateModifyEvent event){
// @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();
answer.stateEmptyCheckAndInit();
Expand All @@ -38,5 +38,4 @@ public String handle(ApplicantStateModifyEvent event){
answerAdaptor.save(answer);
return answer.getApplicantStateOrDefault().getPassState();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import com.econovation.recruit.api.applicant.handler.ApplicantStateUpdateEventHandler;
import com.econovation.recruit.api.applicant.usecase.ApplicantCommandUseCase;
import com.econovation.recruitdomain.common.aop.domainEvent.Events;
import com.econovation.recruitdomain.domains.applicant.domain.state.ApplicantState;
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer;
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswerAdaptor;
import com.econovation.recruitdomain.domains.applicant.domain.state.ApplicantState;
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantRegisterEvent;
import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantStateModifyEvent;
import java.util.Map;
import java.util.UUID;

import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantStateModifyEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -44,7 +43,13 @@ public String execute(String applicantId, String afterState) {
@Override
public UUID execute(Map<String, Object> qna, UUID id) {
ApplicantState nonProcessed = new ApplicantState();
MongoAnswer answer = MongoAnswer.builder().id(id.toString()).qna(qna).year(year).applicantState(nonProcessed).build();
MongoAnswer answer =
MongoAnswer.builder()
.id(id.toString())
.qna(qna)
.year(year)
.applicantState(nonProcessed)
.build();
// 학번으로 중복 체크
// validateRegisterApplicant(qna);
answerAdaptor.save(answer);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.econovation.recruit.api.applicant.service;

import static com.econovation.recruitcommon.consts.RecruitStatic.PASS_STATE_KEY;

import com.econovation.recruit.api.applicant.aggregate.AnswerAggregate;
import com.econovation.recruit.api.applicant.dto.AnswersResponseDto;
import com.econovation.recruit.api.applicant.dto.GetApplicantsStatusResponse;
Expand All @@ -20,8 +22,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static com.econovation.recruitcommon.consts.RecruitStatic.PASS_STATE_KEY;

@Service
@RequiredArgsConstructor
public class ApplicantService implements ApplicantQueryUseCase {
Expand Down Expand Up @@ -99,7 +99,8 @@ public Map<String, Map<String, Object>> findAllApplicantVo(List<String> fields)
@Override
public AnswersResponseDto search(Integer page, String searchKeyword) {
List<MongoAnswer> answers = answerAdaptor.findBySearchKeyword(page, searchKeyword);
answers.forEach(answer -> answer.getQna().put(PASS_STATE_KEY, answer.getApplicantStateOrDefault()));
answers.forEach(
answer -> answer.getQna().put(PASS_STATE_KEY, answer.getApplicantStateOrDefault()));
return AnswersResponseDto.of(
answers.stream().map(MongoAnswer::getQna).toList(),
new PageInfo(answers.size(), page));
Expand Down Expand Up @@ -183,12 +184,14 @@ public List<GetApplicantsStatusResponse> getApplicantsStatus(Integer year, Strin

private List<Map<String, Object>> sortAndAddIds(List<MongoAnswer> result, String sortType) {
sortHelper.sort(result, sortType);
return result.stream().map(
answer -> {
Map<String, Object> qna = answer.getQna();
qna.put("id", answer.getId());
qna.put(PASS_STATE_KEY, answer.getApplicantStateOrDefault());
return qna;
}).toList();
return result.stream()
.map(
answer -> {
Map<String, Object> qna = answer.getQna();
qna.put("id", answer.getId());
qna.put(PASS_STATE_KEY, answer.getApplicantStateOrDefault());
return qna;
})
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,45 @@

@Configuration
@EnableStateMachine
public class ApplicantStateMachineConfig extends EnumStateMachineConfigurerAdapter<PassStates, ApplicantStateEvents> {

public class ApplicantStateMachineConfig
extends EnumStateMachineConfigurerAdapter<PassStates, ApplicantStateEvents> {

@Override
public void configure(StateMachineStateConfigurer<PassStates, ApplicantStateEvents> states) throws Exception {
states
.withStates()
.initial(PassStates.NON_PROCESSED)
.state(PassStates.FIRST_PASSED)
.end(PassStates.FIRST_FAILED)
.end(PassStates.FINAL_PASSED)
.end(PassStates.FINAL_FAILED);

public void configure(StateMachineStateConfigurer<PassStates, ApplicantStateEvents> states)
throws Exception {
states.withStates()
.initial(PassStates.NON_PROCESSED)
.state(PassStates.FIRST_PASSED)
.end(PassStates.FIRST_FAILED)
.end(PassStates.FINAL_PASSED)
.end(PassStates.FINAL_FAILED);
}

/**
*
* @param transitions
* @throws Exception
*
* States
* NON_PROCESSED : 불합격
* FIRST_PASSED : 1차 합격
* FIRST_FAILED : 1차 불합격
* FINAL_PASSED : 최종 합격
* FINAL_FAILED : 최종 불합격
*
* Events
* NON_PASS : 불합격
* PASS : 합격 (다음 단계로 전환)
* <p>States NON_PROCESSED : 불합격 FIRST_PASSED : 1차 합격 FIRST_FAILED : 1차 불합격 FINAL_PASSED :
* 최종 합격 FINAL_FAILED : 최종 불합격
* <p>Events NON_PASS : 불합격 PASS : 합격 (다음 단계로 전환)
*/

@Override
public void configure(StateMachineTransitionConfigurer<PassStates, ApplicantStateEvents> transitions) throws Exception {
public void configure(
StateMachineTransitionConfigurer<PassStates, ApplicantStateEvents> transitions)
throws Exception {
transitions
.withExternal()
.source(PassStates.NON_PROCESSED).target(PassStates.FIRST_PASSED).event(ApplicantStateEvents.PASS)
.source(PassStates.NON_PROCESSED)
.target(PassStates.FIRST_PASSED)
.event(ApplicantStateEvents.PASS)
.and()
.withExternal()
.source(PassStates.FIRST_PASSED).target(PassStates.FINAL_PASSED).event(ApplicantStateEvents.PASS)
.source(PassStates.FIRST_PASSED)
.target(PassStates.FINAL_PASSED)
.event(ApplicantStateEvents.PASS)
.and()
.withExternal()
.source(PassStates.FIRST_PASSED).target(PassStates.FINAL_FAILED).event(ApplicantStateEvents.NON_PASS);
.source(PassStates.FIRST_PASSED)
.target(PassStates.FINAL_FAILED)
.event(ApplicantStateEvents.NON_PASS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
public class ApplicantManager implements ApplicantStateManger {

@Override
public void update(String applicantId, String afterState) {
}
public void update(String applicantId, String afterState) {}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.econovation.recruit.api.applicant.state.support;

import com.econovation.recruitdomain.domains.applicant.domain.state.PeriodStates;
import java.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class PeriodCalculator {

Expand All @@ -15,14 +14,13 @@ public class PeriodCalculator {
@Value("${econovation.recruit.period.finalDiscussion}")
private String finalDiscussionPeriod;

public PeriodStates execute(){
public PeriodStates execute() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime firstDiscussion = LocalDateTime.parse(firstDiscussionPeriod);
LocalDateTime finalDiscussion = LocalDateTime.parse(finalDiscussionPeriod);

if(now.isBefore(firstDiscussion)) return PeriodStates.FIRST_DISCUSSION;
else if(now.isBefore(finalDiscussion)) return PeriodStates.FINAL_DISCUSSION;
if (now.isBefore(firstDiscussion)) return PeriodStates.FIRST_DISCUSSION;
else if (now.isBefore(finalDiscussion)) return PeriodStates.FINAL_DISCUSSION;
else return PeriodStates.END;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public ResponseEntity<String> updateLocationBoard(
description = "navigationId에 해당하는 모든 칸반을 조회합니다.")
@GetMapping("/navigations/{navigation-id}/boards")
public ResponseEntity<List<BoardCardResponseDto>> getBoardByNavigationId(
@PathVariable("navigation-id") Integer navigationId,
@ParameterObject Integer year) {
return new ResponseEntity<>(cardLoadUseCase.getByNavigationId(navigationId, year), HttpStatus.OK);
@PathVariable("navigation-id") Integer navigationId, @ParameterObject Integer year) {
return new ResponseEntity<>(
cardLoadUseCase.getByNavigationId(navigationId, year), HttpStatus.OK);
}

@Operation(summary = "지원서 조회(원하는 field) 만 조회", description = "원하는 field만(리스트) 조회합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ private String extractHopeField(String title) {
log.info("hopeField = {}", titleParts[0]);
return titleParts[0];
}

}
Loading