Skip to content

Commit

Permalink
refactor(profile): major List로 받아오는 거에서 하나 받아오는걸로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobhboy committed Apr 25, 2024
1 parent 88ae866 commit ae61a48
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.sickgyun.server.profile.domain.value;

import java.util.List;

public record Filter(
Boolean isRecruited,
List<Major> majors,
Major major,
Long cardinal
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ public List<Profile> 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<Major> 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,14 +9,14 @@ public record FilterRequest(
@RequestParam(required = false)
Boolean isRecruited,
@RequestParam(required = false)
List<Major> majors,
Major major,
@RequestParam(required = false)
Long cardinal
) {
public Filter toDomain() {
return new Filter(
isRecruited,
majors,
major,
cardinal
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public class QueryProfileServiceTest extends ServiceTest {
}

private List<Profile> 전공이_ETC인_사람() {
return queryProfileService.readAll(new Filter(null, List.of(Major.ETC), null));
return queryProfileService.readAll(new Filter(null, Major.ETC, null));
}

private List<Profile> 전공이_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<Profile> 입학년도가_2021년인_사람_조회() {
Expand Down

0 comments on commit ae61a48

Please sign in to comment.