feat: added an endpoint for fething the project an entrepreneur is associated with
This commit is contained in:
parent
3f18304028
commit
fcf4e1c01d
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -109,4 +109,28 @@ paths:
|
||||
"404":
|
||||
description: Bad Request - sectionCell not found.
|
||||
"401":
|
||||
description: Unauthorized.
|
||||
description: Unauthorized.
|
||||
|
||||
|
||||
/entrepreneur/projects:
|
||||
get:
|
||||
summary: gets the projectId of the project associated with the entrepreneur
|
||||
description: returns a list of projectIds of the projects associated with the entrepreneur
|
||||
tags:
|
||||
- Entrepreneurs API
|
||||
security:
|
||||
- MyINPulse: [MyINPulse-entrepreneur]
|
||||
parameters:
|
||||
responses:
|
||||
"200":
|
||||
description: OK - Section cell updated successfully. Returns the updated cell.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "./main.yaml#/components/schemas/project"
|
||||
"404":
|
||||
description: Bad Request - Invalid input or ID mismatch.
|
||||
"401":
|
||||
description: Unauthorized or identity not found
|
@ -138,6 +138,9 @@ paths:
|
||||
# / ___ \| __/| |
|
||||
# /_/ \_\_| |___|
|
||||
#
|
||||
|
||||
/entrepreneur/projects:
|
||||
$ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1projects"
|
||||
/entrepreneur/projects/request:
|
||||
$ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1projects~1request"
|
||||
/entrepreneur/sectionCells:
|
||||
|
Loading…
x
Reference in New Issue
Block a user