Skip to content

Commit

Permalink
Merge pull request #251 from JNU-econovation/feature/BE-87
Browse files Browse the repository at this point in the history
[FEATURE] 지원서 합/불 상태 필드 추가 및 칸반보드 조회 시 합/불 상태 필드 추가
  • Loading branch information
rlajm1203 authored Sep 13, 2024
2 parents 5bf126b + 83cb8ea commit 6f27666
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.econovation.recruitdomain.common.aop.domainEvent.Events;
import com.econovation.recruitdomain.common.events.WorkCardDeletedEvent;
import com.econovation.recruitdomain.domains.applicant.adaptor.AnswerAdaptor;
import com.econovation.recruitdomain.domains.applicant.domain.ApplicantState;
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer;
import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswerAdaptor;
import com.econovation.recruitdomain.domains.applicant.exception.ApplicantProhibitDeleteException;
Expand Down Expand Up @@ -70,6 +71,10 @@ public List<BoardCardResponseDto> getByNavigationId(Integer navigationId, Intege
Map<String, Integer> yearByAnswerIdMap = mongoAnswers.stream()
.collect(Collectors.toMap(MongoAnswer::getId, MongoAnswer::getYear));

Map<String, ApplicantState> stateByAnswerIdMap = mongoAnswers.stream()
.collect(Collectors.toMap(MongoAnswer::getId,
answer -> answer.getApplicantState()!=null ? answer.getApplicantState() : new ApplicantState()));

List<Card> cards = cardLoadPort.findAll();

Map<Long, String> answerIdByCardIdMap = cards.stream()
Expand Down Expand Up @@ -108,7 +113,7 @@ public List<BoardCardResponseDto> getByNavigationId(Integer navigationId, Intege

for (Board board : boards) {
if (board.getCardType().equals(CardType.INVISIBLE)) {
result.add(BoardCardResponseDto.from(Card.empty(), board, "", "", "", false));
result.add(BoardCardResponseDto.from(Card.empty(), board, "", "", "", false, new ApplicantState()));
continue;
}
Card card = cardByBoardIdMap.get(board.getCardId());
Expand All @@ -118,7 +123,7 @@ public List<BoardCardResponseDto> getByNavigationId(Integer navigationId, Intege
if (answers.isEmpty()) {
result.add(
BoardCardResponseDto.from(
card, board, firstPriority, secondPriority, "", false));
card, board, firstPriority, secondPriority, "", false, new ApplicantState()));
continue;
}
Map<String, Object> applicantAnswers = answers.get(card.getApplicantId());
Expand All @@ -138,9 +143,11 @@ public List<BoardCardResponseDto> getByNavigationId(Integer navigationId, Intege
label.getCardId().equals(card.getId())
&& label.getIdpId().equals(userId));

ApplicantState state = stateByAnswerIdMap.getOrDefault(card.getApplicantId(), new ApplicantState());

result.add(
BoardCardResponseDto.from(
card, board, firstPriority, secondPriority, major, isLabeled));
card, board, firstPriority, secondPriority, major, isLabeled, state));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class RecruitStatic {
public static Set<String> CRETERIA_SET =
new HashSet<>(Arrays.asList("열정/실천력", "동아리 애착", "협업", "태도"));

public static final String PASS_STATE_KEY = "passState";

public static final String APPLICANT_SUCCESS_REGISTER_MESSAGE = "성공적으로 지원됐습니다";
public static final String NO_MATCH_INTERVIEWER_MESSAGE = "해당하는 면접관이 없습니다.";
public static final String BOARD_SUCCESS_REGISTER_MESSAGE = "성공적으로 업무카드가 등록됐습니다";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Arrays;

@Getter
public enum PassStates {
public enum PassStates{

NONPASSED("non-passed"){
@Override
Expand Down Expand Up @@ -43,4 +43,8 @@ public static PassStates findStatus(String status){
.orElseThrow(ApplicantWrongStateException::new);
}

@Override
public String toString() {
return this.status;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package com.econovation.recruitdomain.domains.card.dto;

import com.econovation.recruitdomain.domains.applicant.domain.ApplicantState;
import com.econovation.recruitdomain.domains.applicant.domain.PassStates;
import com.econovation.recruitdomain.domains.board.domain.Board;
import com.econovation.recruitdomain.domains.board.domain.CardType;
import com.econovation.recruitdomain.domains.card.domain.Card;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

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

@Getter
@Data
@Builder
Expand All @@ -25,14 +33,16 @@ public class BoardCardResponseDto {
private String firstPriority;
private String secondPriority;
private Boolean isLabeled;
private Map<String,String> state;

public static BoardCardResponseDto from(
Card card,
Board board,
String firstPriority,
String secondPriority,
String major,
Boolean isLabeled) {
Boolean isLabeled,
ApplicantState state) {
return BoardCardResponseDto.builder()
.boardId(board.getId())
.applicantId(card.getApplicantId())
Expand All @@ -48,6 +58,13 @@ public static BoardCardResponseDto from(
.firstPriority(firstPriority)
.secondPriority(secondPriority)
.isLabeled(isLabeled)
.state(toMap(state))
.build();
}

private static Map<String, String> toMap(ApplicantState state){
Map<String, String> stateMap = new HashMap<>();
stateMap.put(PASS_STATE_KEY, state.getPassState());
return stateMap;
}
}

0 comments on commit 6f27666

Please sign in to comment.