Skip to content

Commit

Permalink
⚙️ :: (#hotfix) filter bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsoftj1123 committed Nov 21, 2023
1 parent 27ee802 commit 877dd30
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.List;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class NumberUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static <E> String joinStringList(List<E> request, String key) {
}

public static List<String> divideString(String content, String key) {
if (content == null || content.isEmpty() || content.length() == 2) {
if (content == null || content.isEmpty()) {
return List.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import team.retum.jobis.domain.recruitment.usecase.TeacherQueryRecruitmentsUseCase;
import team.retum.jobis.domain.recruitment.usecase.UpdateRecruitAreaUseCase;
import team.retum.jobis.domain.recruitment.usecase.UpdateRecruitmentUseCase;
import team.retum.jobis.global.exception.BadRequestException;

import javax.validation.Valid;
import javax.validation.constraints.Positive;
Expand Down Expand Up @@ -102,15 +103,10 @@ public StudentQueryRecruitmentsResponse studentQueryRecruitments(
@RequestParam(value = "job_code", required = false) String jobCode,
@RequestParam(value = "winter_intern", required = false) Boolean winterIntern
) {
List<String> codes = new ArrayList<>(StringUtil.divideString(techCodes, ","));
if (jobCode.length() == 2) codes.add(jobCode);

return studentQueryRecruitmentsUseCase.execute(
companyName,
page - 1,
codes.stream()
.map(Long::parseLong)
.toList(),
this.parseCodes(jobCode, techCodes),
winterIntern
);
}
Expand All @@ -122,14 +118,9 @@ public TotalPageCountResponse studentQueryRecruitmentCount(
@RequestParam(value = "job_code", required = false) String jobCode,
@RequestParam(value = "winter_intern", required = false) Boolean winterIntern
) {
List<String> codes = new ArrayList<>(StringUtil.divideString(techCodes, ","));
if (jobCode.length() == 2) codes.add(jobCode);

return studentQueryRecruitmentsUseCase.getTotalPageCount(
companyName,
codes.stream()
.map(Long::parseLong)
.toList(),
this.parseCodes(jobCode, techCodes),
winterIntern
);
}
Expand Down Expand Up @@ -189,4 +180,17 @@ public void deleteRecruitment(@PathVariable("recruitment-id") Long recruitmentId
public void deleteRecruitArea(@PathVariable("recruit-area-id") Long recruitAreaId) {
deleteRecruitAreaUseCase.execute(recruitAreaId);
}

private List<Long> parseCodes(String jobCode, String techCodes) {
List<String> codes = new ArrayList<>(StringUtil.divideString(techCodes, ","));
if (jobCode != null) codes.add(jobCode);

try {
return codes.stream()
.map(Long::parseLong)
.toList();
} catch (Exception e) {
throw new BadRequestException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public enum GlobalErrorCode implements ErrorProperty {
EXPIRED_TOKEN(HttpStatus.UNAUTHORIZED, "Token Expired"),
INVALID_TOKEN(HttpStatus.UNAUTHORIZED, "Invalid Token"),

MAIL_SEND_FAIL(HttpStatus.NOT_FOUND, "Mail Send Fail");
MAIL_SEND_FAIL(HttpStatus.NOT_FOUND, "Mail Send Fail"),

BAD_REQUEST(HttpStatus.BAD_REQUEST, "Bad Request");

private final HttpStatus status;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package team.retum.jobis.global.exception;

import team.retum.jobis.common.error.JobisException;
import team.retum.jobis.global.error.exception.GlobalErrorCode;

public class BadRequestException extends JobisException {

public static final JobisException EXCEPTION = new BadRequestException();

public BadRequestException() {
super(GlobalErrorCode.BAD_REQUEST);
}
}

0 comments on commit 877dd30

Please sign in to comment.