backend-api #6

Merged
piair merged 107 commits from backend-api into main 2025-03-26 19:04:09 +01:00
42 changed files with 1295 additions and 1146 deletions
Showing only changes of commit 04a73073c1 - Show all commits

View File

@ -1,40 +0,0 @@
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.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.management.relation.RoleNotFoundException;
@SpringBootApplication
@RestController
public class GetUserInfo {
@GetMapping("/unauth/random")
public boolean rand(@RequestHeader("Authorization") String token) throws RoleNotFoundException {
System.err.println(token);
return Math.random() > 0.5;
}
@GetMapping("/admin/random")
public boolean rand2() {
return Math.random() > 0.5;
}
@GetMapping("/entrepreneur/random")
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);
}
}

View File

@ -2,7 +2,7 @@
* Source: https://github.com/ChristianHuff-DEV/secure-spring-rest-api-using-keycloak/blob/main/src/main/java/io/betweendata/RestApi/security/oauth2/KeycloakJwtRolesConverter.java * Source: https://github.com/ChristianHuff-DEV/secure-spring-rest-api-using-keycloak/blob/main/src/main/java/io/betweendata/RestApi/security/oauth2/KeycloakJwtRolesConverter.java
* edited by Pierre Tellier * edited by Pierre Tellier
*/ */
package enseirb.myinpulse.security; package enseirb.myinpulse.config;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;

View File

@ -2,8 +2,6 @@ package enseirb.myinpulse.config;
import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole; import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
import enseirb.myinpulse.security.KeycloakJwtRolesConverter;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -58,9 +56,9 @@ public class WebSecurityCustomConfiguration {
http.authorizeHttpRequests( http.authorizeHttpRequests(
authorize -> authorize ->
authorize authorize
.requestMatchers("/entrepreneur/**") .requestMatchers("/entrepreneur/**", "/shared/**")
.access(hasRole("REALM_MyINPulse-entrepreneur")) .access(hasRole("REALM_MyINPulse-entrepreneur"))
.requestMatchers("/admin/**") .requestMatchers("/admin/**", "/shared/**")
.access(hasRole("REALM_MyINPulse-admin")) .access(hasRole("REALM_MyINPulse-admin"))
.requestMatchers("/unauth/**") .requestMatchers("/unauth/**")
.permitAll() .permitAll()

View File

@ -1,9 +1,9 @@
package enseirb.myinpulse.api; package enseirb.myinpulse.controller;
import enseirb.myinpulse.api.datatypes.Project; import enseirb.myinpulse.model.*;
import enseirb.myinpulse.api.datatypes.ProjectDecision; import enseirb.myinpulse.service.AdminApiService;
import enseirb.myinpulse.api.datatypes.Report; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -11,52 +11,65 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
public class AdminApi { public class AdminApi {
private final AdminApiService adminApiService;
@Autowired
AdminApi(AdminApiService adminApiService) {
this.adminApiService = adminApiService;
}
/** /**
* TODO * TODO: description
* *
* @return a list of all project managed by the current admin user * @return a list of all project managed by the current admin user
*/ */
@GetMapping("/admin/projects") @GetMapping("/admin/projects")
public void getProjects() {} public Iterable<Administrateurs> getProjects() {
return adminApiService.getProjects();
}
/** /**
* TODO: Why in admin instead of shared ? * TODO: Why in admin instead of shared ? + desc
* *
* @return a list of upcoming appointments for the current user * @return a list of upcoming appointments for the current user
*/ */
@GetMapping("/admin/appointments/upcoming") @GetMapping("/admin/appointments/upcoming")
public void getUpcomingAppointments() {} public Iterable<Appointment> getUpcomingAppointments() {
return adminApiService.getUpcomingAppointments();
}
/** /**
* TODO * TODO: description
* *
* @return a list of current unvalidated projects, waiting to be accepted * @return a list of current unvalidated projects, waiting to be accepted
*/ */
@GetMapping("/admin/projects/pending") @GetMapping("/admin/projects/pending")
public void getPendingProjects() {} public Iterable<Project> getPendingProjects() {
return adminApiService.getPendingProjects();
}
/** /**
* TODO * Endpoint used to make a decision about a project.
*
* <p>Endpoint used to make a decision about a project.
* *
* @return the status code of the request * @return the status code of the request
*/ */
@PostMapping("/admin/projects/decision") @PostMapping("/admin/projects/decision")
public void validateProject(@RequestBody ProjectDecision decision) {} public void validateProject(@RequestBody ProjectDecision decision) {
adminApiService.validateProject(decision);
}
/** /**
* TODO * Endpoint used to manually add a project by an admin
*
* <p>Endpoint used to manually add a project by an admin
* *
* @return the status code of the request * @return the status code of the request
*/ */
@PostMapping("/admin/project/add") @PostMapping("/admin/project/add")
public void addNewProject(@RequestBody Project project) {} public void addNewProject(@RequestBody Project project) {
adminApiService.addNewProject(project);
}
/** /**
* TODO: shouldn't it be an UPDATE request ? * TODO: shouldn't it be an PUT request ? / What is the rerun type
* *
* <p>Endpoint used to add a new report to an appointment * <p>Endpoint used to add a new report to an appointment
* *
@ -64,7 +77,9 @@ public class AdminApi {
*/ */
@PostMapping("/admin/appoitements/report/{appointmentId}") @PostMapping("/admin/appoitements/report/{appointmentId}")
public void createAppointmentReport( public void createAppointmentReport(
@PathVariable String appointmentId, @RequestBody Report report) {} @PathVariable String appointmentId, @RequestBody Report report) {
adminApiService.createAppointmentReport(appointmentId, report);
}
/** /**
* TODO: Shouldn't a project be kept in history ? 2 different endpoints ? * TODO: Shouldn't a project be kept in history ? 2 different endpoints ?
@ -74,5 +89,7 @@ public class AdminApi {
* @return the status code of the request * @return the status code of the request
*/ */
@DeleteMapping("/admin/projects/remove/{projectId}") @DeleteMapping("/admin/projects/remove/{projectId}")
public void deleteProject(@PathVariable String projectId) {} public void deleteProject(@PathVariable String projectId) {
adminApiService.deleteProject(projectId);
}
} }

View File

@ -1,51 +1,69 @@
package enseirb.myinpulse.api; package enseirb.myinpulse.controller;
import enseirb.myinpulse.api.datatypes.LCSection; import enseirb.myinpulse.model.LCSection;
import enseirb.myinpulse.api.datatypes.Project; import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.service.EntrepreneurApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@SpringBootApplication @SpringBootApplication
@RestController @RestController
public class EntrepreneurApi { public class EntrepreneurApi {
private final EntrepreneurApiService entrepreneurApiService;
@Autowired
EntrepreneurApi(EntrepreneurApiService entrepreneurApiService) {
this.entrepreneurApiService = entrepreneurApiService;
}
/** /**
* TODO * TODO: check return type
* *
* <p>Endpoint used to update a LC section. * <p>Endpoint used to update a LC section.
* *
* @return status code * @return status code
*/ */
@PutMapping("/entrepreneur/lcsection/modify/{sectionId}") @PutMapping("/entrepreneur/lcsection/modify/{sectionId}")
public void editLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {} public void editLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {
entrepreneurApiService.editLCSection(sectionId, section);
}
/** /**
* TODO * TODO: checkReturn Type
* *
* <p>Endpoint used to delete a LC section * <p>Endpoint used to delete a LC section
* *
* @return status code * @return status code
*/ */
@DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}") @DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}")
public void removeLCSection(@PathVariable String sectionId) {} public void removeLCSection(@PathVariable String sectionId) {
entrepreneurApiService.removeLCSection(sectionId);
}
/** /**
* TODO * TODO: check return type
* *
* <p>Endpoint used to create a new LC section * <p>Endpoint used to create a new LC section
* *
* @return status code * @return status code
*/ */
@PostMapping("/entrepreneur/lcsection/add/{sectionId}") @PostMapping("/entrepreneur/lcsection/add/{sectionId}")
public void addLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {} public void addLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {
entrepreneurApiService.addLCSection(sectionId, section);
}
/** /**
* TODO * TODO: check return type
* *
* <p>Endpoint used to request the creation of a new project * <p>Endpoint used to request the creation of a new project
* *
* @return status code * @return status code
*/ */
@PostMapping("/entrepreneur/project/request") @PostMapping("/entrepreneur/project/request")
public void requestNewProject(@RequestBody Project project) {} public void requestNewProject(@RequestBody Project project) {
entrepreneurApiService.requestNewProject(project);
}
} }

View File

@ -1,7 +1,12 @@
package enseirb.myinpulse.api; package enseirb.myinpulse.controller;
import enseirb.myinpulse.api.datatypes.Appointment; import enseirb.myinpulse.model.Administrateurs;
import enseirb.myinpulse.model.Appointment;
import enseirb.myinpulse.model.Entrepreneurs;
import enseirb.myinpulse.model.Sections;
import enseirb.myinpulse.service.SharedApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -9,6 +14,13 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
public class SharedApi { public class SharedApi {
private final SharedApiService sharedApiService;
@Autowired
SharedApi(SharedApiService sharedApiService) {
this.sharedApiService = sharedApiService;
}
/** /**
* TODO: It does not looks like a good id to have the title and the date in the url. What even * 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: is the title btw ? if this is the LC section, wouldn't it be better to use an ID ?
@ -19,20 +31,22 @@ public class SharedApi {
* @return a list of lean canvas sections * @return a list of lean canvas sections
*/ */
@GetMapping("/shared/project/lcsection/{projectId}/{title}/{date}") @GetMapping("/shared/project/lcsection/{projectId}/{title}/{date}")
public void getLCSection( public Iterable<Sections> getLCSection(
@PathVariable("projectId") String projectId, @PathVariable("projectId") String projectId,
@PathVariable("title") String title, @PathVariable("title") String title,
@PathVariable("date") String date) {} @PathVariable("date") String date) {
return sharedApiService.getLCSection(projectId, title, date);
}
/** /**
* TODO * Endpoint used to get entrepreneurs details
*
* <p>Endpoint used to get entrepreneurs details
* *
* @return a list of all entrepreneurs in a project * @return a list of all entrepreneurs in a project
*/ */
@GetMapping("/shared/entrepreneurs/{projectId}") @GetMapping("/shared/entrepreneurs/{projectId}")
public void getEntrepreneursByProjectId(@PathVariable int projectId) {} public Iterable<Entrepreneurs> getEntrepreneursByProjectId(@PathVariable int projectId) {
return sharedApiService.getEntrepreneursByProjectId(projectId);
}
/** /**
* TODO: is it really useful for the admin ? We can already get all the project of the current * TODO: is it really useful for the admin ? We can already get all the project of the current
@ -43,7 +57,9 @@ public class SharedApi {
* @return a list of all project managed by the current admin user * @return a list of all project managed by the current admin user
*/ */
@GetMapping("/shared/projects/admin/{projectId}") @GetMapping("/shared/projects/admin/{projectId}")
public void getAdminByProjectId(@PathVariable int projectId) {} public Iterable<Administrateurs> getAdminByProjectId(@PathVariable int projectId) {
return sharedApiService.getAdminByProjectId(projectId);
}
/** /**
* TODO: Should it really be all appointments? all future appointments ? a flag to choose \\ * TODO: Should it really be all appointments? all future appointments ? a flag to choose \\
@ -54,25 +70,27 @@ public class SharedApi {
* @return a list of all appointments. * @return a list of all appointments.
*/ */
@GetMapping("/shared/projects/appointments/{projectId}") @GetMapping("/shared/projects/appointments/{projectId}")
public void getAppointmentsByProjectId(@PathVariable int projectId) {} public Iterable<Appointment> getAppointmentsByProjectId(@PathVariable int projectId) {
return sharedApiService.getAppointmentsByProjectId(projectId);
}
/** /**
* TODO: Shouldn't the last two parameters be swapped ? * Endpoint used to generate a PDF report
*
* <p>Endpoint used to generate a PDF report
* *
* @return a PDF file? TODO: how does that works ? * @return a PDF file? TODO: how does that works ?
*/ */
@GetMapping("/shared/projects/appointments/report/{appointmentId}") @GetMapping("/shared/projects/appointments/report/{appointmentId}")
public void getPDFReport(@PathVariable int appointmentId) {} public void getPDFReport(@PathVariable int appointmentId) {
sharedApiService.getPDFReport(appointmentId);
}
/** /**
* TODO * TODO
* *
* <p> * @return TODO
*
* @return a list of all project managed by the current admin user
*/ */
@PostMapping("/shared/appointment/request") @PostMapping("/shared/appointment/request")
public void createAppointmentRequest(@RequestBody Appointment appointment) {} public void createAppointmentRequest(@RequestBody Appointment appointment) {
sharedApiService.createAppointmentRequest(appointment);
}
} }

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.exceptions; package enseirb.myinpulse.exception;
public class RoleNotFoudException extends RuntimeException { public class RoleNotFoudException extends RuntimeException {
public RoleNotFoudException(String message) { public RoleNotFoudException(String message) {

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.exceptions; package enseirb.myinpulse.exception;
public class UserNotFoundException extends RuntimeException { public class UserNotFoundException extends RuntimeException {
public UserNotFoundException(String message) { public UserNotFoundException(String message) {

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.persistence.PrimaryKeyJoinColumn; import jakarta.persistence.PrimaryKeyJoinColumn;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.api.datatypes; package enseirb.myinpulse.model;
public class Appointment { public class Appointment {
int validated; int validated;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.api.datatypes; package enseirb.myinpulse.model;
// TODO: is this redundant with the Section class from the database ? // 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: In the one hand it represent the same data, and on the other it should be much lighter.

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.api.datatypes; package enseirb.myinpulse.model;
public class Project { public class Project {
int projectId; int projectId;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.api.datatypes; package enseirb.myinpulse.model;
public class ProjectDecision { public class ProjectDecision {
int projectId; int projectId;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.api.datatypes; package enseirb.myinpulse.model;
public class Report { public class Report {
int projectId; int projectId;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.utils.keycloak.datatypes; package enseirb.myinpulse.model;
public class RoleRepresentation { public class RoleRepresentation {
public String id; public String id;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.utils.keycloak.datatypes; package enseirb.myinpulse.model;
public class UserRepresentation { public class UserRepresentation {
public String id; public String id;

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;

View File

@ -1,52 +0,0 @@
package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@RestController
public class ComptesRendusController {
private final ComptesRendusRepository comptesRendusRepository;
public ComptesRendusController(ComptesRendusRepository comptesRendusRepository) {
this.comptesRendusRepository = comptesRendusRepository;
}
@GetMapping("/ComptesRendus")
@ResponseBody
public Iterable<ComptesRendus> allComptesRendus() {
return this.comptesRendusRepository.findAll();
}
@GetMapping("/ComptesRendus/{id}")
public ComptesRendus getComptesRendusById(@PathVariable Long id) {
Optional<ComptesRendus> compteRendu = this.comptesRendusRepository.findById(id);
if (compteRendu.isEmpty()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
}
return compteRendu.get();
}
@PostMapping("/ComptesRendus")
public ComptesRendus addComptesRendus(@RequestBody ComptesRendus comptesRendus) {
return this.comptesRendusRepository.save(comptesRendus);
}
@PostMapping("/ComptesRendus/{id}")
public ComptesRendus updateProjets(@PathVariable Long id, String contenu_compte_rendu) {
Optional<ComptesRendus> compteRendu = this.comptesRendusRepository.findById(id);
if (compteRendu.isEmpty()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
}
if (contenu_compte_rendu != null) {
compteRendu.get().setContenu_compte_rendu(contenu_compte_rendu);
}
return this.comptesRendusRepository.save(compteRendu.get());
}
}

View File

@ -1,6 +1,6 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.Administrateurs; import enseirb.myinpulse.model.Administrateurs;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -1,9 +1,9 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.ComptesRendus; import enseirb.myinpulse.model.ComptesRendus;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource @RepositoryRestResource
public interface ComptesRendusRepository extends JpaRepository<ComptesRendus, Long> {} public interface ComptesRendusRepository extends JpaRepository<ComptesRendus, Integer> {}

View File

@ -1,6 +1,6 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.Entrepreneurs; import enseirb.myinpulse.model.Entrepreneurs;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -1,6 +1,6 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.Projets; import enseirb.myinpulse.model.Projets;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -1,6 +1,6 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.RendezVous; import enseirb.myinpulse.model.RendezVous;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -1,6 +1,6 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.Sections; import enseirb.myinpulse.model.Sections;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -1,6 +1,6 @@
package enseirb.myinpulse.postgres_db.repository; package enseirb.myinpulse.repository;
import enseirb.myinpulse.postgres_db.model.Utilisateurs; import enseirb.myinpulse.model.Utilisateurs;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;

View File

@ -0,0 +1,46 @@
package enseirb.myinpulse.service;
import enseirb.myinpulse.model.*;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
@Service
public class AdminApiService {
// TODO
public Iterable<Administrateurs> getProjects() {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public Iterable<Appointment> getUpcomingAppointments() {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public Iterable<Project> getPendingProjects() {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public void validateProject(ProjectDecision decision) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public void addNewProject(Project project) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public void createAppointmentReport(String appointmentId, Report report) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public void deleteProject(String projectId) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
}

View File

@ -0,0 +1,29 @@
package enseirb.myinpulse.service;
import enseirb.myinpulse.model.LCSection;
import enseirb.myinpulse.model.Project;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
@Service
public class EntrepreneurApiService {
public void editLCSection(String sectionId, LCSection section) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void removeLCSection(String sectionId) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void addLCSection(String sectionId, LCSection section) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void requestNewProject(Project project) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
}

View File

@ -1,10 +1,10 @@
package enseirb.myinpulse.utils.keycloak; package enseirb.myinpulse.service;
import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.http.MediaType.APPLICATION_JSON;
import enseirb.myinpulse.exceptions.UserNotFoundException; import enseirb.myinpulse.exception.UserNotFoundException;
import enseirb.myinpulse.utils.keycloak.datatypes.RoleRepresentation; import enseirb.myinpulse.model.RoleRepresentation;
import enseirb.myinpulse.utils.keycloak.datatypes.UserRepresentation; import enseirb.myinpulse.model.UserRepresentation;
import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient;

View File

@ -0,0 +1,36 @@
package enseirb.myinpulse.service;
import enseirb.myinpulse.model.*;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;
@Service
public class SharedApiService {
public Iterable<Sections> getLCSection(String projectId, String title, String date) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public Iterable<Entrepreneurs> getEntrepreneursByProjectId(int projectId) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public Iterable<Administrateurs> getAdminByProjectId(int projectId) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public Iterable<Appointment> getAppointmentsByProjectId(int projectId) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void getPDFReport(int appointmentId) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void createAppointmentRequest(Appointment appointment) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
}

View File

@ -0,0 +1,34 @@
package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.ComptesRendus;
import enseirb.myinpulse.repository.ComptesRendusRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@Service
public class CompteRenduService {
private final ComptesRendusRepository comptesRendusRepository;
@Autowired
CompteRenduService(ComptesRendusRepository comptesRendusRepository) {
this.comptesRendusRepository = comptesRendusRepository;
}
ComptesRendus getComptesRendusById(int id) {
Optional<ComptesRendus> compteRendu = comptesRendusRepository.findById(id);
if (compteRendu.isEmpty()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
}
return compteRendu.get();
}
// TODO: do some validation
void saveCompteRendu(ComptesRendus compteRendu) {
comptesRendusRepository.save(compteRendu);
}
}

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import enseirb.myinpulse.postgres_db.model.Administrateurs; import enseirb.myinpulse.model.Administrateurs;
import enseirb.myinpulse.postgres_db.repository.AdministrateursRepository; import enseirb.myinpulse.repository.AdministrateursRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@ -0,0 +1,43 @@
package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import org.springframework.web.bind.annotation.*;
@RestController
public class ComptesRendusController {
/*
private final ComptesRendusRepository comptesRendusRepository;
@Autowired
public ComptesRendusController(ComptesRendusRepository comptesRendusRepository) {
this.comptesRendusRepository = comptesRendusRepository;
}
@GetMapping("/ComptesRendus")
@ResponseBody
public Iterable<ComptesRendus> allComptesRendus() {
System.out.println("\n\n");
System.out.println(comptesRendusRepository);
System.out.println("\n\n");
return this.comptesRendusRepository.findAll();
}
@PostMapping("/ComptesRendus")
public ComptesRendus addComptesRendus(@RequestBody ComptesRendus comptesRendus) {
return this.comptesRendusRepository.save(comptesRendus);
}
@PostMapping("/ComptesRendus/{id}")
public ComptesRendus updateProjets(@PathVariable Long id, String contenu_compte_rendu) {
Optional<ComptesRendus> compteRendu = this.comptesRendusRepository.findById(id);
if (compteRendu.isEmpty()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
}
if (contenu_compte_rendu != null) {
compteRendu.get().setContenu_compte_rendu(contenu_compte_rendu);
}
return this.comptesRendusRepository.save(compteRendu.get());
}
*/
}

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import enseirb.myinpulse.postgres_db.model.Entrepreneurs; import enseirb.myinpulse.model.Entrepreneurs;
import enseirb.myinpulse.postgres_db.repository.EntrepreneursRepository; import enseirb.myinpulse.repository.EntrepreneursRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import enseirb.myinpulse.postgres_db.model.Projets; import enseirb.myinpulse.model.Projets;
import enseirb.myinpulse.postgres_db.repository.ProjetsRepository; import enseirb.myinpulse.repository.ProjetsRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@ -1,15 +1,17 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import enseirb.myinpulse.model.RendezVous;
import enseirb.myinpulse.repository.RendezVousRepository;
import enseirb.myinpulse.postgres_db.model.RendezVous;
import enseirb.myinpulse.postgres_db.repository.RendezVousRepository;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired; 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;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Optional;
@RestController @RestController
public class RendezVousController { public class RendezVousController {

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import enseirb.myinpulse.postgres_db.model.Sections; import enseirb.myinpulse.model.Sections;
import enseirb.myinpulse.postgres_db.repository.SectionsRepository; import enseirb.myinpulse.repository.SectionsRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import enseirb.myinpulse.postgres_db.model.Utilisateurs; import enseirb.myinpulse.model.Utilisateurs;
import enseirb.myinpulse.postgres_db.repository.UtilisateursRepository; import enseirb.myinpulse.repository.UtilisateursRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;