Skip to content

Commit

Permalink
[feat] : maxPage 파라미터 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackBean99 committed Sep 2, 2023
1 parent 4ebf84c commit 4d4a013
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 19 deletions.
Binary file modified server/.gradle/7.6.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified server/.gradle/7.6.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified server/.gradle/7.6.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified server/.gradle/7.6.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified server/.gradle/7.6.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified server/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified server/.gradle/file-system.probe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import com.econovation.recruitcommon.annotation.XssProtected;
import com.econovation.recruitdomain.domains.applicant.dto.BlockRequestDto;
import com.econovation.recruitdomain.domains.applicant.dto.TimeTableVo;
import com.econovation.recruitdomain.domains.dto.ApplicantPaginationResponseDto;
import com.econovation.recruitdomain.domains.dto.QuestionRequestDto;
import com.econovation.recruitdomain.domains.timetable.domain.TimeTable;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -45,7 +47,8 @@ public class ApplicantController {
@ApiErrorExceptionsExample(CreateApplicantExceptionDocs.class)
@XssProtected
@PostMapping("/applicants")
public ResponseEntity registerApplicant(@RequestBody List<BlockRequestDto> blockElements) {
public ResponseEntity registerApplicant(
@RequestBody @Valid List<BlockRequestDto> blockElements) {
UUID applicantId = applicantRegisterUseCase.execute(blockElements);
return new ResponseEntity<>(applicantId, HttpStatus.OK);
}
Expand All @@ -65,9 +68,8 @@ public ResponseEntity<List<Map<String, String>>> getApplicants() {

@Operation(summary = "모든 지원자의 지원서를 페이지 단위로(1페이지당 8개) 조회합니다.")
@GetMapping("/page/{page}/applicants")
public ResponseEntity<List<Map<String, String>>> getApplicantsByPage(
public ResponseEntity<ApplicantPaginationResponseDto> getApplicantsByPage(
// TODO 정렬 기준 추가
// @PathVariable(value = "page") Integer page, String sortType) {
@PathVariable(value = "page") Integer page) {
return new ResponseEntity<>(answerLoadUseCase.execute(page), HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.econovation.recruitcommon.exception.OutOfIndexException;
import com.econovation.recruitdomain.domains.applicant.adaptor.AnswerAdaptor;
import com.econovation.recruitdomain.domains.applicant.domain.Answer;
import com.econovation.recruitdomain.domains.dto.ApplicantPaginationResponseDto;
import com.econovation.recruitdomain.domains.score.adaptor.ScoreAdaptor;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -128,11 +129,16 @@ public List<Map<String, String>> execute() {
}

@Override
public List<Map<String, String>> execute(Integer page) {
public ApplicantPaginationResponseDto execute(Integer page) {
if (page < 1) throw OutOfIndexException.EXCEPTION;
List<Answer> answers = answerAdaptor.findAll(page);
List<Map<String, String>> results = splitByAnswersInApplicantId(answers);
return results;
// maxPage
Integer maxPage = results.size() / 8;
return ApplicantPaginationResponseDto.builder()
.applicants(results)
.maxPage(maxPage + 1)
.build();

// if (sortType.equals("score")) {
// Map -> id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@ public void execute(String type, String name, Integer parentId) {

@Override
public void execute(List<QuestionRequestDto> questions) {
questionAdaptor.saveAll(
// DB 내에 있는 질문은 기존에 있는 것은 생략하고 저장한다
List<Question> questionList = questionAdaptor.findAll();
List<Question> filteredQuestions =
questions.stream()
.filter(
question ->
questionList.stream()
.noneMatch(
q ->
q.getName()
.equals(
question.getName())))
.map(
question ->
Question.builder()
.questionType(question.getType())
.name(question.getName())
.parentId(question.getParentId())
.build())
.collect(Collectors.toList()));
.collect(Collectors.toList());
questionAdaptor.saveAll(filteredQuestions);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.econovation.recruit.api.applicant.usecase;

import com.econovation.recruitcommon.annotation.UseCase;
import com.econovation.recruitdomain.domains.dto.ApplicantPaginationResponseDto;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -13,7 +14,7 @@ public interface AnswerLoadUseCase {

List<Map<String, String>> execute();

List<Map<String, String>> execute(Integer page);
ApplicantPaginationResponseDto execute(Integer page);
// List<Map<String, String>> execute(Integer page, String sortType);

Map<String, String> execute(String applicantId, List<String> fields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@RequiredArgsConstructor
@EnableWebSecurity
public class SecurityConfig {

private final FilterConfig filterConfig;

@Value("${swagger.user}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
public class ApplicantRegisterEventHandler {
private final SlackMessageProvider slackMessageProvider;
private final SlackProperties slackProperties;

private final CardAdaptor cardAdaptor;
private final BoardRegisterUseCase boardRegisterUseCase;

Expand All @@ -40,7 +39,7 @@ public void handle(ApplicantRegisterEvent applicantRegistEvent) {
applicantRegistEvent.getApplicantId(),
applicantRegistEvent.getHopeField(),
card.getId());
slackMessageProvider.sendMessage(slackProperties.getUrl(), message);
// slackMessageProvider.sendMessage(slackProperties.getUrl(), message);
}

private String generateApplicantRegisterMessage(ApplicantRegisterEvent applicantRegistEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public class RecruitStatic {
"/api-docs"
};
public static final String[] RolePattern = {
"ROLE_TF",
"ROLE_PRESIDENT",
"ROLE_OPERATION",
"ROLE_TF", "ROLE_PRESIDENT", "ROLE_OPERATION",
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.hibernate.validator.constraints.Length;

@Getter
@RequiredArgsConstructor
public class BlockRequestDto {
// private String type;
private String name;
// 한글 기준으로 1000자 이하
@Length(max = 1000)
private String answer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.econovation.recruitdomain.domains.dto;

import java.util.List;
import java.util.Map;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class ApplicantPaginationResponseDto {
List<Map<String, String>> applicants;
Integer maxPage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ public Interviewer loadInterviewerByEmail(String email) {
.findByEmail(email)
.orElseThrow(() -> InterviewerNotFoundException.EXCEPTION);
}

@Override
public Optional<Interviewer> loadOptionalInterviewerByEmail(String email) {
return interviewerRepository
.findByEmail(email);
return interviewerRepository.findByEmail(email);
}


public List<Interviewer> saveAll(List<Interviewer> interviewer) {
return interviewerRepository.saveAll(interviewer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.econovation.recruitcommon.exception.RecruitCodeException;

public class InterviewerAlreadySubmitException extends RecruitCodeException {
public static final InterviewerAlreadySubmitException EXCEPTION = new InterviewerAlreadySubmitException();
public static final InterviewerAlreadySubmitException EXCEPTION =
new InterviewerAlreadySubmitException();

private InterviewerAlreadySubmitException() {
super(InterviewerErrorCode.INTERVIEWER_ALREADY_SUBMIT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface InterviewerLoadPort {
List<Interviewer> loadInterviewerByIdpIds(List<Long> idpIds);

List<Interviewer> findAll();

Interviewer loadInterviewerByEmail(String email);

Optional<Interviewer> loadOptionalInterviewerByEmail(String email);
Expand Down

0 comments on commit 4d4a013

Please sign in to comment.