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.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
@ -100,7 +101,7 @@ public class Controller {
|
||||
}
|
||||
|
||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||
cacheAccesDefinitionRepository.findById(0); // bearbeitet
|
||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||
@ -286,5 +287,19 @@ public class Controller {
|
||||
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