Implemented Backend for getting the RankingList

This commit is contained in:
Maximilian Leopold 2019-03-31 14:46:39 +02:00
parent 9b64672a32
commit 61330b3f0b
2 changed files with 14 additions and 0 deletions

View File

@ -301,5 +301,12 @@ public class Controller {
}
return new Gson().toJson(bearbeitetList);
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getRankingList")
@ResponseBody
String getRankingList() {
return new Gson().toJson(userRepository.getRankingList());
}
}

View File

@ -1,8 +1,15 @@
package hhn.labsw.bugageocaching.repositories;
import hhn.labsw.bugageocaching.entities.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import java.util.Collection;
import java.util.List;
public interface UserRepository extends CrudRepository<User, Integer> {
User findByUsername(String username);
@Query(value = "SELECT u.username, u.ranking_points_sum from user u order by ranking_points_sum DESC", nativeQuery = true)
List<Object[]> getRankingList();
}