Compare commits
3 Commits
back-postg
...
11ab5e1dc4
Author | SHA1 | Date | |
---|---|---|---|
11ab5e1dc4 | |||
3cb12dab4f | |||
0a9d83655f |
@ -0,0 +1,78 @@
|
|||||||
|
package enseirb.myinpulse.api;
|
||||||
|
|
||||||
|
import enseirb.myinpulse.api.datatypes.Project;
|
||||||
|
import enseirb.myinpulse.api.datatypes.ProjectDecision;
|
||||||
|
|
||||||
|
import enseirb.myinpulse.api.datatypes.Report;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@RestController
|
||||||
|
public class AdminApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* @return a list of all project managed by the current admin user
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/projects")
|
||||||
|
public void getProjects() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Why in admin instead of shared ?
|
||||||
|
*
|
||||||
|
* @return a list of upcoming appointments for the current user
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/appointments/upcoming")
|
||||||
|
public void getUpcomingAppointments() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* @return a list of current unvalidated projects, waiting to be accepted
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/projects/pending")
|
||||||
|
public void getPendingProjects() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to make a decision about a project.
|
||||||
|
*
|
||||||
|
* @return the status code of the request
|
||||||
|
*/
|
||||||
|
@PostMapping("/admin/projects/decision")
|
||||||
|
public void validateProject(@RequestBody ProjectDecision decision) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to manually add a project by an admin
|
||||||
|
*
|
||||||
|
* @return the status code of the request
|
||||||
|
*/
|
||||||
|
@PostMapping("/admin/project/add")
|
||||||
|
public void addNewProject(@RequestBody Project project) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: shouldn't it be an UPDATE request ?
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to add a new report to an appointment
|
||||||
|
*
|
||||||
|
* @return the status code of the request
|
||||||
|
*/
|
||||||
|
@PostMapping("/admin/appoitements/report/{appointmentId}")
|
||||||
|
public void createAppointmentReport(
|
||||||
|
@PathVariable String appointmentId, @RequestBody Report report) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Shouldn't a project be kept in history ? 2 different endpoints ?
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to completely remove a project.
|
||||||
|
*
|
||||||
|
* @return the status code of the request
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/admin/projects/remove/{projectId}")
|
||||||
|
public void deleteProject(@PathVariable String projectId) {}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package enseirb.myinpulse.api;
|
||||||
|
|
||||||
|
import enseirb.myinpulse.api.datatypes.LCSection;
|
||||||
|
import enseirb.myinpulse.api.datatypes.Project;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@RestController
|
||||||
|
public class EntrepreneurApi {
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to update a LC section.
|
||||||
|
*
|
||||||
|
* @return status code
|
||||||
|
*/
|
||||||
|
@PutMapping("/entrepreneur/lcsection/modify/{sectionId}")
|
||||||
|
public void editLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to delete a LC section
|
||||||
|
*
|
||||||
|
* @return status code
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}")
|
||||||
|
public void removeLCSection(@PathVariable String sectionId) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to create a new LC section
|
||||||
|
*
|
||||||
|
* @return status code
|
||||||
|
*/
|
||||||
|
@PostMapping("/entrepreneur/lcsection/add/{sectionId}")
|
||||||
|
public void addLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to request the creation of a new project
|
||||||
|
*
|
||||||
|
* @return status code
|
||||||
|
*/
|
||||||
|
@PostMapping("/entrepreneur/project/request")
|
||||||
|
public void requestNewProject(@RequestBody Project project) {}
|
||||||
|
}
|
@ -1,27 +1,20 @@
|
|||||||
package enseirb.myinpulse.api;
|
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.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.security.Principal;
|
|
||||||
|
|
||||||
import javax.management.relation.RoleNotFoundException;
|
import javax.management.relation.RoleNotFoundException;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
public class GetUserInfo {
|
public class GetUserInfo {
|
||||||
// TODO: understand how to get data
|
|
||||||
@GetMapping("/getUserInfo")
|
|
||||||
public Object user(Principal principal) {
|
|
||||||
System.out.println("GetUserInfo + " + principal);
|
|
||||||
System.out.println(SecurityContextHolder.getContext().getAuthentication());
|
|
||||||
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
|
||||||
@GetMapping("/unauth/random")
|
@GetMapping("/unauth/random")
|
||||||
public boolean rand(@RequestHeader("Authorization") String token) throws RoleNotFoundException {
|
public boolean rand(@RequestHeader("Authorization") String token) throws RoleNotFoundException {
|
||||||
System.err.println(token);
|
System.err.println(token);
|
||||||
@ -37,4 +30,11 @@ public class GetUserInfo {
|
|||||||
public boolean rand3() {
|
public boolean rand3() {
|
||||||
return Math.random() > 0.5;
|
return Math.random() > 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@GetMapping("/unauth/dev")
|
||||||
|
public ComptesRendus testApi(ComptesRendusRepository repository) {
|
||||||
|
ComptesRendusController comptesRendusController = new ComptesRendusController(repository);
|
||||||
|
return comptesRendusController.getComptesRendusById((long) 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
package enseirb.myinpulse.api;
|
||||||
|
|
||||||
|
import enseirb.myinpulse.api.datatypes.Appointment;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@RestController
|
||||||
|
public class SharedApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: It does not looks like a good id to have the title and the date in the url. What even
|
||||||
|
* TODO: is the title btw ? if this is the LC section, wouldn't it be better to use an ID ?
|
||||||
|
* TODO: choose return type, cf comment in LCSection
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to get the data inside the lean canvas
|
||||||
|
*
|
||||||
|
* @return a list of lean canvas sections
|
||||||
|
*/
|
||||||
|
@GetMapping("/shared/project/lcsection/{projectId}/{title}/{date}")
|
||||||
|
public void getLCSection(
|
||||||
|
@PathVariable("projectId") String projectId,
|
||||||
|
@PathVariable("title") String title,
|
||||||
|
@PathVariable("date") String date) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to get entrepreneurs details
|
||||||
|
*
|
||||||
|
* @return a list of all entrepreneurs in a project
|
||||||
|
*/
|
||||||
|
@GetMapping("/shared/entrepreneurs/{projectId}")
|
||||||
|
public void getEntrepreneursByProjectId(@PathVariable int projectId) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: is it really useful for the admin ? We can already get all the project of the current
|
||||||
|
* administrator.
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to get the administrator of a project.
|
||||||
|
*
|
||||||
|
* @return a list of all project managed by the current admin user
|
||||||
|
*/
|
||||||
|
@GetMapping("/shared/projects/admin/{projectId}")
|
||||||
|
public void getAdminByProjectId(@PathVariable int projectId) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Should it really be all appointments? all future appointments ? a flag to choose \\
|
||||||
|
* TODO: between both ?
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to get all appointments of a single project.
|
||||||
|
*
|
||||||
|
* @return a list of all appointments.
|
||||||
|
*/
|
||||||
|
@GetMapping("/shared/projects/appointments/{projectId}")
|
||||||
|
public void getAppointmentsByProjectId(@PathVariable int projectId) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Shouldn't the last two parameters be swapped ?
|
||||||
|
*
|
||||||
|
* <p>Endpoint used to generate a PDF report
|
||||||
|
*
|
||||||
|
* @return a PDF file? TODO: how does that works ?
|
||||||
|
*/
|
||||||
|
@GetMapping("/shared/projects/appointments/report/{appointmentId}")
|
||||||
|
public void getPDFReport(@PathVariable int appointmentId) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @return a list of all project managed by the current admin user
|
||||||
|
*/
|
||||||
|
@PostMapping("/shared/appointment/request")
|
||||||
|
public void createAppointmentRequest(@RequestBody Appointment appointment) {}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package enseirb.myinpulse.api.datatypes;
|
||||||
|
|
||||||
|
public class Appointment {
|
||||||
|
int validated;
|
||||||
|
int[] akserId;
|
||||||
|
int[] destId;
|
||||||
|
String date; // TODO: date type ?
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package enseirb.myinpulse.api.datatypes;
|
||||||
|
|
||||||
|
// TODO: is this redundant with the Section class from the database ?
|
||||||
|
// TODO: In the one hand it represent the same data, and on the other it should be much lighter.
|
||||||
|
// TODO: btw why does a LC section have an administrator ?
|
||||||
|
|
||||||
|
public class LCSection {}
|
@ -0,0 +1,7 @@
|
|||||||
|
package enseirb.myinpulse.api.datatypes;
|
||||||
|
|
||||||
|
public class Project {
|
||||||
|
int projectId;
|
||||||
|
String projectName;
|
||||||
|
String projectDescription;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package enseirb.myinpulse.api.datatypes;
|
||||||
|
|
||||||
|
public class ProjectDecision {
|
||||||
|
int projectId;
|
||||||
|
int adminId;
|
||||||
|
int isAccepted;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package enseirb.myinpulse.api.datatypes;
|
||||||
|
|
||||||
|
public class Report {
|
||||||
|
int projectId;
|
||||||
|
String reportContent;
|
||||||
|
}
|
@ -3,7 +3,6 @@ package enseirb.myinpulse.postgres_db.controller;
|
|||||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||||
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
|
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
@ -13,7 +12,11 @@ import java.util.Optional;
|
|||||||
@RestController
|
@RestController
|
||||||
public class ComptesRendusController {
|
public class ComptesRendusController {
|
||||||
|
|
||||||
@Autowired ComptesRendusRepository comptesRendusRepository;
|
private final ComptesRendusRepository comptesRendusRepository;
|
||||||
|
|
||||||
|
public ComptesRendusController(ComptesRendusRepository comptesRendusRepository) {
|
||||||
|
this.comptesRendusRepository = comptesRendusRepository;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/ComptesRendus")
|
@GetMapping("/ComptesRendus")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -53,7 +53,7 @@ const CustomRequest = ref("");
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Unauth API call</td>
|
<td>Unauth API call</td>
|
||||||
<td>
|
<td>
|
||||||
<button @click="callApi('random3')">call</button>
|
<button @click="callApi('unauth/dev')">call</button>
|
||||||
</td>
|
</td>
|
||||||
<td>res</td>
|
<td>res</td>
|
||||||
<td id="3"></td>
|
<td id="3"></td>
|
||||||
|
Reference in New Issue
Block a user