From ae61a48ad4907b38449ddf71d87e35e2beec48ac Mon Sep 17 00:00:00 2001 From: bo Date: Thu, 25 Apr 2024 11:01:49 +0900 Subject: [PATCH] =?UTF-8?q?refactor(profile):=20major=20List=EB=A1=9C=20?= =?UTF-8?q?=EB=B0=9B=EC=95=84=EC=98=A4=EB=8A=94=20=EA=B1=B0=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=95=98=EB=82=98=20=EB=B0=9B=EC=95=84=EC=98=A4?= =?UTF-8?q?=EB=8A=94=EA=B1=B8=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sickgyun/server/profile/domain/value/Filter.java | 4 +--- .../infra/database/QueryProfileRepositoryImpl.java | 8 ++++---- .../server/profile/presentation/dto/FilterRequest.java | 6 ++---- .../server/profile/service/QueryProfileServiceTest.java | 4 ++-- 4 files changed, 9 insertions(+), 13 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 161d5ff..8c68ad3 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 @@ -1,10 +1,8 @@ package com.sickgyun.server.profile.domain.value; -import java.util.List; - public record Filter( Boolean isRecruited, - List majors, + Major major, Long cardinal ) { } diff --git a/main-server/src/main/java/com/sickgyun/server/profile/infra/database/QueryProfileRepositoryImpl.java b/main-server/src/main/java/com/sickgyun/server/profile/infra/database/QueryProfileRepositoryImpl.java index 5dcf3cf..0f6fb13 100644 --- a/main-server/src/main/java/com/sickgyun/server/profile/infra/database/QueryProfileRepositoryImpl.java +++ b/main-server/src/main/java/com/sickgyun/server/profile/infra/database/QueryProfileRepositoryImpl.java @@ -31,18 +31,18 @@ public List findAllFiltered(Filter filter) { .leftJoin(profile.writer, user) .fetchJoin() .where( - majorFilter(filter.majors()), + majorFilter(filter.major()), recruitedFilter(filter.isRecruited()), 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) { 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 99d12c3..7ad285f 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 @@ -1,7 +1,5 @@ package com.sickgyun.server.profile.presentation.dto; -import java.util.List; - import org.springframework.web.bind.annotation.RequestParam; import com.sickgyun.server.profile.domain.value.Filter; @@ -11,14 +9,14 @@ public record FilterRequest( @RequestParam(required = false) Boolean isRecruited, @RequestParam(required = false) - List majors, + Major major, @RequestParam(required = false) Long cardinal ) { public Filter toDomain() { return new Filter( isRecruited, - majors, + major, cardinal ); } diff --git a/main-server/src/test/java/com/sickgyun/server/profile/service/QueryProfileServiceTest.java b/main-server/src/test/java/com/sickgyun/server/profile/service/QueryProfileServiceTest.java index 0efe9fe..0561d95 100644 --- a/main-server/src/test/java/com/sickgyun/server/profile/service/QueryProfileServiceTest.java +++ b/main-server/src/test/java/com/sickgyun/server/profile/service/QueryProfileServiceTest.java @@ -94,11 +94,11 @@ public class QueryProfileServiceTest extends ServiceTest { } private List 전공이_ETC인_사람() { - return queryProfileService.readAll(new Filter(null, List.of(Major.ETC), null)); + return queryProfileService.readAll(new Filter(null, Major.ETC, null)); } private List 전공이_GAME_혹은_BACKEND_이고_취업한_사람() { - return queryProfileService.readAll(new Filter(true, List.of(Major.GAME, Major.BACKEND), null)); + return queryProfileService.readAll(new Filter(true, Major.GAME, null)); } private List 입학년도가_2021년인_사람_조회() {