feat: added an endpoint for fething the project an entrepreneur is associated with
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
package enseirb.myinpulse.controller;
|
||||
|
||||
|
||||
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.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@ -42,6 +44,19 @@ public class EntrepreneurApi {
|
||||
sectionCellId, content, principal.getClaimAsString("email"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint used to update a LC section.
|
||||
*
|
||||
* @return status code
|
||||
*/
|
||||
@GetMapping("/entrepreneur/projects")
|
||||
public Iterable<Project> getEntrepreneurProjectId(
|
||||
@PathVariable Long sectionCellId,
|
||||
@RequestBody String content,
|
||||
@AuthenticationPrincipal Jwt principal) {
|
||||
return entrepreneurApiService.getProjectIdViaClaim(principal.getClaimAsString("email"));
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: checkReturn Type
|
||||
*
|
||||
|
@ -14,7 +14,10 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class EntrepreneurApiService {
|
||||
@ -219,4 +222,13 @@ public class EntrepreneurApiService {
|
||||
}
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "User already exists in the system");
|
||||
}
|
||||
|
||||
public Iterable<Project> getProjectIdViaClaim(String email) {
|
||||
Long UserId = this.userService.getUserByEmail(email).getIdUser();
|
||||
Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(UserId);
|
||||
List<Project> Project_List = new ArrayList<>();
|
||||
;
|
||||
Project_List.add(entrepreneur.getProjectParticipation());
|
||||
return Project_List;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user