use of pl.morecraft.dev.settler.web.dto.UserListDTO in project Settler by EmhyrVarEmreis.
the class TransactionService method getMostUsedUsers.
public ResponseEntity<List<UserListDTO>> getMostUsedUsers(Long count) {
QUser user = QUser.user;
QTransaction transaction = QTransaction.transaction;
QRedistribution redistribution = QRedistribution.redistribution;
List<User> userList = new JPAQuery<>(entityManager).from(user).select(user).where(user.id.in(JPAExpressions.selectFrom(transaction).select(redistribution.id.user.id).leftJoin(redistribution).on(redistribution.id.parent.id.eq(transaction.id)).where(transaction.creator.id.eq(Security.currentUser().getId())).groupBy(redistribution.id.user.id).orderBy(redistribution.id.user.id.count().desc()).limit(count))).fetch();
Type listType = new TypeToken<List<UserListDTO>>() {
}.getType();
List<UserListDTO> userListDTOList = getModelMapper().map(userList, listType);
return new ResponseEntity<>(userListDTOList, HttpStatus.OK);
}
Aggregations