added getMyCaches API method
This commit is contained in:
parent
8fad8e427e
commit
dcce7b31e8
@ -10,6 +10,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -100,7 +101,7 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||||
cacheAccesDefinitionRepository.findById(0); // bearbeitet
|
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||||
@ -286,5 +287,19 @@ public class Controller {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
|
@RequestMapping("/api/getMyCaches")
|
||||||
|
@ResponseBody
|
||||||
|
String getMyCaches(@RequestParam String token) {
|
||||||
|
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||||
|
ArrayList<Bearbeitet> bearbeitetList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Bearbeitet bearbeitet : bearbeitetRepository.findAll()) {
|
||||||
|
if (bearbeitet.getUser().getId() == user.getId()) {
|
||||||
|
bearbeitetList.add(bearbeitet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Gson().toJson(bearbeitetList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user