Skip to content

Commit c402091

Browse files
committed
feat: 임원진 전체 조회 시 정렬 기준 설정 (DASOMBE-21)
1 parent 174d94e commit c402091

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import dmu.dasom.api.domain.executive.entity.ExecutiveEntity;
77
import dmu.dasom.api.domain.executive.repository.ExecutiveRepository;
88
import lombok.RequiredArgsConstructor;
9+
import org.springframework.data.domain.Sort;
910
import org.springframework.stereotype.Service;
1011
import org.springframework.transaction.annotation.Transactional;
1112

@@ -31,11 +32,13 @@ public ExecutiveResponseDto getExecutiveById(Long id) {
3132
// 임원진 전체 조회
3233
// 이름, 직책, 깃허브 주소 출력
3334
public List<ExecutiveListResponseDto> getAllExecutives() {
34-
List<ExecutiveEntity> executives = executiveRepository.findAll();
35+
// 전체 조회 시 정렬
36+
// 기준 sortOrder -> 직책 -> 이름
37+
Sort sort = Sort.by(Sort.Direction.ASC, "sortOrder")
38+
.and(Sort.by(Sort.Direction.ASC, "position"))
39+
.and(Sort.by(Sort.Direction.DESC, "name"));
3540

36-
List<Long> executiveIds = executives.stream()
37-
.map(ExecutiveEntity::getId)
38-
.toList();
41+
List<ExecutiveEntity> executives = executiveRepository.findAll(sort);
3942

4043
return executives.stream()
4144
.map(executiveEntity -> executiveEntity.toListResponseDto())

0 commit comments

Comments
 (0)