Skip to content

Commit

Permalink
refactor: 어드민용 기수순 유저 조회 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jj0526 committed Jan 22, 2025
1 parent da91da2 commit facae24
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.List;

import static leets.weeth.domain.user.application.dto.response.UserResponseDto.AdminResponse;
import static leets.weeth.domain.user.domain.entity.enums.UsersOrderBy.NAME_ASCENDING;
import static leets.weeth.domain.user.domain.entity.enums.UsersOrderBy.*;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -57,7 +57,20 @@ public List<AdminResponse> findAllByAdmin(UsersOrderBy orderBy) {
})
.toList();
}
// To do : 추후 기수 분리 후 작업 예정
if (orderBy.equals(CARDINAL_DESCENDING)){
return userGetService.findAll().stream()
.sorted(Comparator.comparingInt((user -> (StatusPriority.fromStatus(user.getStatus())).getPriority())))
.map(user -> {
List<UserCardinal> userCardinals = userCardinalGetService.getUserCardinals(user);
return mapper.toAdminResponse(user, userCardinals);
})
.sorted((adminResponse1, adminResponse2) -> {
Integer maxCardinal1 = adminResponse1.cardinals().stream().max(Integer::compareTo).orElse(0);
Integer maxCardinal2 = adminResponse2.cardinals().stream().max(Integer::compareTo).orElse(0);
return maxCardinal2.compareTo(maxCardinal1);
})
.toList();
}

return null;
}
Expand Down

0 comments on commit facae24

Please # to comment.