From 000269f9f3838fe9bd52e7d909c52fa4482c1869 Mon Sep 17 00:00:00 2001 From: Woongbin06 Date: Wed, 24 Apr 2024 22:55:03 +0900 Subject: [PATCH] =?UTF-8?q?refactor(profile)=20:=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=EC=9D=98=20=ED=95=84=ED=84=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/profile/domain/value/Filter.java | 4 ++-- .../database/ProfileQueryRepositoryImpl.java | 20 ++++++++----------- .../presentation/dto/FilterRequest.java | 12 +++++------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/main-server/src/main/java/com/sickgyun/server/profile/domain/value/Filter.java b/main-server/src/main/java/com/sickgyun/server/profile/domain/value/Filter.java index 07ce96e..59420e7 100644 --- a/main-server/src/main/java/com/sickgyun/server/profile/domain/value/Filter.java +++ b/main-server/src/main/java/com/sickgyun/server/profile/domain/value/Filter.java @@ -4,7 +4,7 @@ public record Filter( Boolean isRecruited, - List majors, - String cardinals + Major major, + Long cardinal ) { } diff --git a/main-server/src/main/java/com/sickgyun/server/profile/infra/database/ProfileQueryRepositoryImpl.java b/main-server/src/main/java/com/sickgyun/server/profile/infra/database/ProfileQueryRepositoryImpl.java index b8f960f..e840b7b 100644 --- a/main-server/src/main/java/com/sickgyun/server/profile/infra/database/ProfileQueryRepositoryImpl.java +++ b/main-server/src/main/java/com/sickgyun/server/profile/infra/database/ProfileQueryRepositoryImpl.java @@ -32,18 +32,18 @@ public List findAllFiltered(Filter filter) { .leftJoin(profile.writer, user) .fetchJoin() .where( - majorFilter(filter.majors()), + majorFilter(filter.major()), recruitedFilter(filter.isRecruited()), - admissionYearFilter(filter.cardinals()) + cardinalFilter(filter.cardinal()) ).fetch(); } - private BooleanExpression majorFilter(List majors) { - if (majors == null) { + private BooleanExpression majorFilter(Major major) { + if (major == null) { return null; } - return profile.information.major.in(majors); + return profile.information.major.eq(major); } private BooleanExpression recruitedFilter(Boolean isRecruited) { @@ -54,15 +54,11 @@ private BooleanExpression recruitedFilter(Boolean isRecruited) { return profile.company.isNotEmpty(); } - private BooleanExpression admissionYearFilter(String admissionYear) { - if (admissionYear == null) { + private BooleanExpression cardinalFilter(Long cardinal) { + if (cardinal == null) { return null; } - List list = Arrays.stream(admissionYear.split("-")) - .map(Integer::parseInt) - .toList(); - - return user.cardinal.between(list.get(0), list.get(1)); + return user.cardinal.eq(cardinal); } } diff --git a/main-server/src/main/java/com/sickgyun/server/profile/presentation/dto/FilterRequest.java b/main-server/src/main/java/com/sickgyun/server/profile/presentation/dto/FilterRequest.java index c653d87..c1b82db 100644 --- a/main-server/src/main/java/com/sickgyun/server/profile/presentation/dto/FilterRequest.java +++ b/main-server/src/main/java/com/sickgyun/server/profile/presentation/dto/FilterRequest.java @@ -9,17 +9,17 @@ public record FilterRequest( @RequestParam(required = false) - Boolean isReqruited, + Boolean isRecruited, @RequestParam(required = false) - List majors, + Major major, @RequestParam(required = false) - String cardinals + Long cardinal ) { public Filter toDomain() { return new Filter( - isReqruited, - majors, - cardinals + isRecruited, + major, + cardinal ); } }