2025-02-26 14:51:02 +01:00

79 lines
2.5 KiB
Java

package enseirb.myinpulse.controller;
import enseirb.myinpulse.model.SectionCell;
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 editSectionCell(
@PathVariable Long sectionId,
@RequestBody SectionCell sectionCell,
@AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.editSectionCell(
sectionId, sectionCell, principal.getClaimAsString("email"));
}
/**
* TODO: checkReturn Type
*
* <p>Endpoint used to delete a LC section
*
* @return status code
*/
@DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}")
public void removeSectionCell(
@PathVariable Long sectionId, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.removeSectionCell(sectionId, principal.getClaimAsString("email"));
}
/**
* TODO: check return type
*
* <p>Endpoint used to create a new LC section
*
* @return status code
*/
@PostMapping("/entrepreneur/lcsection/add") // remove id from doc aswell
public void addLCSection(
@RequestBody SectionCell sectionCell, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.addSectionCell(sectionCell, 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"));
}
}