feat: query to database from and unaut endpoint
This commit is contained in:
parent
b4c05f8c59
commit
0a9d83655f
@ -1,5 +1,10 @@
|
||||
package enseirb.myinpulse.api;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.controller.ComptesRendusController;
|
||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -7,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class GetUserInfo {
|
||||
|
||||
@GetMapping("/unauth/random")
|
||||
public boolean rand() {
|
||||
return Math.random() > 0.5;
|
||||
@ -21,4 +27,11 @@ public class GetUserInfo {
|
||||
public boolean rand3() {
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@GetMapping("/unauth/dev")
|
||||
public ComptesRendus testApi(ComptesRendusRepository repository) {
|
||||
ComptesRendusController comptesRendusController = new ComptesRendusController(repository);
|
||||
return comptesRendusController.getComptesRendusById((long) 1);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
@ -13,7 +12,11 @@ import java.util.Optional;
|
||||
@RestController
|
||||
public class ComptesRendusController {
|
||||
|
||||
@Autowired ComptesRendusRepository comptesRendusRepository;
|
||||
private final ComptesRendusRepository comptesRendusRepository;
|
||||
|
||||
public ComptesRendusController(ComptesRendusRepository comptesRendusRepository) {
|
||||
this.comptesRendusRepository = comptesRendusRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/ComptesRendus")
|
||||
@ResponseBody
|
||||
|
@ -50,7 +50,7 @@ import { callApi } from "@/services/api.ts";
|
||||
<tr>
|
||||
<td>Unauth API call</td>
|
||||
<td>
|
||||
<button @click="callApi('random3')">call</button>
|
||||
<button @click="callApi('unauth/dev')">call</button>
|
||||
</td>
|
||||
<td>res</td>
|
||||
<td id="3"></td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user