5 Commits

Author SHA1 Message Date
4698aa549f feat: frontend call now include the token and send the email from the token to backen servie
All checks were successful
Format / formatting (push) Successful in 6s
CI / build (push) Successful in 11s
2025-02-19 12:09:37 +01:00
04a73073c1 feat: switch to a service layer architecture
All checks were successful
Format / formatting (push) Successful in 6s
CI / build (push) Successful in 11s
2025-02-18 22:15:14 +01:00
11ab5e1dc4 feat: merged Keycloak / postgres
All checks were successful
Format / formatting (push) Successful in 7s
CI / build (push) Successful in 11s
2025-02-18 17:20:08 +01:00
3cb12dab4f feat: created signature of all api functions
All checks were successful
Format / formatting (push) Successful in 8s
CI / build (push) Successful in 11s
2025-02-18 10:50:21 +01:00
0a9d83655f feat: query to database from and unaut endpoint
All checks were successful
Format / formatting (push) Successful in 9s
CI / build (push) Successful in 12s
2025-02-13 21:57:41 +01:00
43 changed files with 1505 additions and 1089 deletions

View File

@ -1,40 +0,0 @@
package enseirb.myinpulse.api;
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.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import javax.management.relation.RoleNotFoundException;
@SpringBootApplication
@RestController
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")
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;
}
}

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
* edited by Pierre Tellier
*/
package enseirb.myinpulse.security;
package enseirb.myinpulse.config;
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 enseirb.myinpulse.security.KeycloakJwtRolesConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -58,9 +56,9 @@ public class WebSecurityCustomConfiguration {
http.authorizeHttpRequests(
authorize ->
authorize
.requestMatchers("/entrepreneur/**")
.requestMatchers("/entrepreneur/**", "/shared/**")
.access(hasRole("REALM_MyINPulse-entrepreneur"))
.requestMatchers("/admin/**")
.requestMatchers("/admin/**", "/shared/**")
.access(hasRole("REALM_MyINPulse-admin"))
.requestMatchers("/unauth/**")
.permitAll()

View File

@ -0,0 +1,102 @@
package enseirb.myinpulse.controller;
import enseirb.myinpulse.model.*;
import enseirb.myinpulse.service.AdminApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@RestController
public class AdminApi {
private final AdminApiService adminApiService;
@Autowired
AdminApi(AdminApiService adminApiService) {
this.adminApiService = adminApiService;
}
/**
* TODO: description
*
* @return a list of all project managed by the current admin user
*/
@GetMapping("/admin/projects")
public Iterable<Administrateurs> getProjects(@AuthenticationPrincipal Jwt principal) {
return adminApiService.getProjects(principal.getClaimAsString("email"));
}
/**
* TODO: Why in admin instead of shared ? + desc
*
* @return a list of upcoming appointments for the current user
*/
@GetMapping("/admin/appointments/upcoming")
public Iterable<Appointment> getUpcomingAppointments(@AuthenticationPrincipal Jwt principal) {
return adminApiService.getUpcomingAppointments(principal.getClaimAsString("email"));
}
/**
* TODO: description
*
* @return a list of current unvalidated projects, waiting to be accepted
*/
@GetMapping("/admin/projects/pending")
public Iterable<Project> getPendingProjects() {
return adminApiService.getPendingProjects();
}
/**
* Endpoint used to make a decision about a project.
*
* <p>The decision must contains the administrator
*
* @return the status code of the request
*/
@PostMapping("/admin/projects/decision")
public void validateProject(@RequestBody ProjectDecision decision) {
adminApiService.validateProject(decision);
}
/**
* 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) {
adminApiService.addNewProject(project);
}
/**
* TODO: shouldn't it be an PUT request ? / What is the rerun type
*
* <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,
@AuthenticationPrincipal Jwt principal) {
adminApiService.createAppointmentReport(
appointmentId, report, principal.getClaimAsString("email"));
}
/**
* 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) {
adminApiService.deleteProject(projectId);
}
}

View File

@ -0,0 +1,81 @@
package enseirb.myinpulse.controller;
import enseirb.myinpulse.model.LCSection;
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.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@RestController
public class EntrepreneurApi {
private final EntrepreneurApiService entrepreneurApiService;
@Autowired
EntrepreneurApi(EntrepreneurApiService entrepreneurApiService) {
this.entrepreneurApiService = entrepreneurApiService;
}
/**
* TODO: check return type
*
* <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,
@AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.editLCSection(
sectionId, section, principal.getClaimAsString("email"));
}
/**
* TODO: checkReturn Type
*
* <p>Endpoint used to delete a LC section
*
* @return status code
*/
@DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}")
public void removeLCSection(
@PathVariable String sectionId, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.removeLCSection(sectionId, principal.getClaimAsString("email"));
}
/**
* TODO: check return type
*
* <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,
@AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.addLCSection(
sectionId, section, principal.getClaimAsString("email"));
}
/**
* TODO: check return type
*
* <p>Endpoint used to request the creation of a new project
*
* @return status code
*/
@PostMapping("/entrepreneur/project/request")
public void requestNewProject(
@RequestBody Project project, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.requestNewProject(project, principal.getClaimAsString("email"));
}
}

View File

@ -0,0 +1,99 @@
package enseirb.myinpulse.controller;
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.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@RestController
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: 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 Iterable<Sections> getLCSection(
@PathVariable("projectId") String projectId,
@PathVariable("title") String title,
@PathVariable("date") String date,
@AuthenticationPrincipal Jwt principal) {
return sharedApiService.getLCSection(
projectId, title, date, principal.getClaimAsString("email"));
}
/**
* Endpoint used to get entrepreneurs details
*
* @return a list of all entrepreneurs in a project
*/
@GetMapping("/shared/entrepreneurs/{projectId}")
public Iterable<Entrepreneurs> getEntrepreneursByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getEntrepreneursByProjectId(
projectId, principal.getClaimAsString("email"));
}
/**
* 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 Iterable<Administrateurs> getAdminByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getAdminByProjectId(projectId, principal.getClaimAsString("email"));
}
/**
* Endpoint used to get all appointments of a single project.
*
* @return a list of all appointments.
*/
@GetMapping("/shared/projects/appointments/{projectId}")
public Iterable<Appointment> getAppointmentsByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getAppointmentsByProjectId(
projectId, principal.getClaimAsString("email"));
}
/**
* 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, @AuthenticationPrincipal Jwt principal) {
sharedApiService.getPDFReport(appointmentId, principal.getClaimAsString("email"));
}
/**
* @return TODO
*/
@PostMapping("/shared/appointment/request")
public void createAppointmentRequest(
@RequestBody Appointment appointment, @AuthenticationPrincipal Jwt principal) {
sharedApiService.createAppointmentRequest(appointment, principal.getClaimAsString("email"));
}
}

View File

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

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.exceptions;
package enseirb.myinpulse.exception;
public class UserNotFoundException extends RuntimeException {
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.PrimaryKeyJoinColumn;

View File

@ -0,0 +1,8 @@
package enseirb.myinpulse.model;
public class Appointment {
int validated;
int[] akserId;
int[] destId;
String date; // TODO: date type ?
}

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model;
package enseirb.myinpulse.model;
import jakarta.persistence.*;
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.Entity;

View File

@ -0,0 +1,7 @@
package enseirb.myinpulse.model;
// 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 {}

View File

@ -0,0 +1,7 @@
package enseirb.myinpulse.model;
public class Project {
int projectId;
String projectName;
String projectDescription;
}

View File

@ -0,0 +1,7 @@
package enseirb.myinpulse.model;
public class ProjectDecision {
int projectId;
int adminId;
int isAccepted;
}

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model;
package enseirb.myinpulse.model;
import jakarta.persistence.*;
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.validation.constraints.NotNull;

View File

@ -0,0 +1,6 @@
package enseirb.myinpulse.model;
public class Report {
int projectId;
String reportContent;
}

View File

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

View File

@ -1,4 +1,4 @@
package enseirb.myinpulse.postgres_db.model;
package enseirb.myinpulse.model;
import jakarta.persistence.*;
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 String id;

View File

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

View File

@ -1,49 +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.beans.factory.annotation.Autowired;
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 {
@Autowired 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.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.rest.core.annotation.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.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.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.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.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.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(String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public Iterable<Appointment> getUpcomingAppointments(String mail) {
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, String email) {
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, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void removeLCSection(String sectionId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void addLCSection(String sectionId, LCSection section, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void requestNewProject(Project project, String mail) {
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 enseirb.myinpulse.exceptions.UserNotFoundException;
import enseirb.myinpulse.utils.keycloak.datatypes.RoleRepresentation;
import enseirb.myinpulse.utils.keycloak.datatypes.UserRepresentation;
import enseirb.myinpulse.exception.UserNotFoundException;
import enseirb.myinpulse.model.RoleRepresentation;
import enseirb.myinpulse.model.UserRepresentation;
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, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public Iterable<Entrepreneurs> getEntrepreneursByProjectId(int projectId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public Iterable<Administrateurs> getAdminByProjectId(int projectId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public Iterable<Appointment> getAppointmentsByProjectId(int projectId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void getPDFReport(int appointmentId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
public void createAppointmentRequest(Appointment appointment, String mail) {
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.postgres_db.repository.AdministrateursRepository;
import enseirb.myinpulse.model.Administrateurs;
import enseirb.myinpulse.repository.AdministrateursRepository;
import org.springframework.beans.factory.annotation.Autowired;
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.postgres_db.repository.EntrepreneursRepository;
import enseirb.myinpulse.model.Entrepreneurs;
import enseirb.myinpulse.repository.EntrepreneursRepository;
import org.springframework.beans.factory.annotation.Autowired;
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.postgres_db.repository.ProjetsRepository;
import enseirb.myinpulse.model.Projets;
import enseirb.myinpulse.repository.ProjetsRepository;
import org.springframework.beans.factory.annotation.Autowired;
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.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Optional;
@RestController
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.postgres_db.repository.SectionsRepository;
import enseirb.myinpulse.model.Sections;
import enseirb.myinpulse.repository.SectionsRepository;
import org.springframework.beans.factory.annotation.Autowired;
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.postgres_db.repository.UtilisateursRepository;
import enseirb.myinpulse.model.Utilisateurs;
import enseirb.myinpulse.repository.UtilisateursRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;

View File

@ -53,7 +53,7 @@ const CustomRequest = ref("");
<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>