Skip to content

Commit

Permalink
[MERGE/#113] 중복된 학과 이름 학과 리스트에 저장하지 않는 기능 추가
Browse files Browse the repository at this point in the history
[FEAT] #113 - 중복된 학과 이름 학과 리스트에 저장하지 않는 기능 추가
  • Loading branch information
ckkim817 authored Jul 17, 2024
2 parents fbed93c + 8af78b0 commit 0df6866
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.sopt.seonyakServer.domain.university.service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.sopt.seonyakServer.domain.university.dto.SearchDeptResponse;
Expand Down Expand Up @@ -36,8 +38,10 @@ public List<SearchDeptResponse> searchDept(
}

List<Department> departments = deptRepository.findByUnivIdAndDeptNameContaining(univName, deptName);
Set<String> uniqueDeptNames = new HashSet<>();

return departments.stream()
.filter(department -> uniqueDeptNames.add(department.getDeptName()))
.map(department -> SearchDeptResponse.of(
department.getDeptName(),
department.isClosed())
Expand Down

0 comments on commit 0df6866

Please sign in to comment.