Added helper class for rankinglist
This commit is contained in:
parent
da75fbb922
commit
b9a975c101
@ -1,24 +1,21 @@
|
||||
package hhn.labsw.bugageocaching.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import hhn.labsw.bugageocaching.entities.*;
|
||||
import hhn.labsw.bugageocaching.helper.RankingListHelper;
|
||||
import hhn.labsw.bugageocaching.repositories.*;
|
||||
import hhn.labsw.bugageocaching.util.FinderUtil;
|
||||
import hhn.labsw.bugageocaching.util.VerificationUtil;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.createCacheUtil;
|
||||
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.deleteCacheUtil;
|
||||
@ -122,7 +119,7 @@ public class Controller {
|
||||
|
||||
|
||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||
@ -369,19 +366,19 @@ public class Controller {
|
||||
// TODO SQL-Anfrage geschrieben, müssen uns nurnoch überlegen wie wir das ganze zurückgeben.
|
||||
// TODO Da die Daten jetzt über mehrere Klassen verteilt sind, können wir nicht nur ein einzelnes Objekt zurückliefern.
|
||||
// TODO Wäre eigentlich am Besten, wenn wir einfach das array zurückgeben, das frontend sollte ja ohne probleme daraus dann die Daten rausholen können.
|
||||
|
||||
// Ich hab mal eine Hilfsklasse erstellt, damit die Daten in einer schöneren Form ins Frontend kommen und da quasi nichts geändert
|
||||
// werden muss. Ich konnte es noch nicht ausprobieren, da die se server down sind (11:05 Uhr)
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getRankingList")
|
||||
@ResponseBody
|
||||
public ResponseEntity getRankingList() {
|
||||
|
||||
List<User> sendBackUsers = new LinkedList<>();
|
||||
List<RankingListHelper> sendBackUsers = new LinkedList<>();
|
||||
List<Object[]> rankingUsers = userRepository.getRankingList();
|
||||
for (Object[] obj : rankingUsers) {
|
||||
User u = new User();
|
||||
u.setId((int) obj[0]);
|
||||
u.setUsername((String) obj[1]);
|
||||
//u.setRankingPointsSum((int) obj[2]);
|
||||
sendBackUsers.add(u);
|
||||
RankingListHelper tmp = new RankingListHelper((String) obj[1], (int) obj[2]);
|
||||
sendBackUsers.add(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package hhn.labsw.bugageocaching.helper;
|
||||
|
||||
public class RankingListHelper {
|
||||
|
||||
private String username;
|
||||
private int ranking_Points;
|
||||
|
||||
public RankingListHelper(String username, int ranking_Points) {
|
||||
this.username = username;
|
||||
this.ranking_Points = ranking_Points;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public int getRanking_Points() {
|
||||
return ranking_Points;
|
||||
}
|
||||
|
||||
public void setRanking_Points(int ranking_Points) {
|
||||
this.ranking_Points = ranking_Points;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user