Compare commits
	
		
			2 Commits
		
	
	
		
			85b4fe6a4c
			...
			abfe92bc87
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | abfe92bc87 | ||
| f2448a029f | 
| @@ -95,4 +95,22 @@ public class EntrepreneurApi { | ||||
|             @RequestBody Project project, @AuthenticationPrincipal Jwt principal) { | ||||
|         entrepreneurApiService.requestNewProject(project, principal.getClaimAsString("email")); | ||||
|     } | ||||
|  | ||||
|     /* | ||||
|      * <p>Endpoint to check if project is has already been validated by an admin | ||||
|      */ | ||||
|     @GetMapping("/entrepreneur/projects/project-is-active") | ||||
|     public Boolean checkIfProjectValidated(@AuthenticationPrincipal Jwt principal) { | ||||
|         return entrepreneurApiService.checkIfEntrepreneurProjectActive( | ||||
|                 principal.getClaimAsString("email")); | ||||
|     } | ||||
|  | ||||
|     /* | ||||
|      * <p>Endpoint to check if a user requested a project (used when project is pending) | ||||
|      */ | ||||
|     @GetMapping("/entrepreneur/projects/has-pending-request") | ||||
|     public Boolean checkIfHasRequested(@AuthenticationPrincipal Jwt principal) { | ||||
|         return entrepreneurApiService.entrepreneurHasPendingRequestedProject( | ||||
|                 principal.getClaimAsString("email")); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,12 @@ | ||||
| package enseirb.myinpulse.service; | ||||
|  | ||||
| import static enseirb.myinpulse.model.ProjectDecisionValue.PENDING; | ||||
| import static enseirb.myinpulse.model.ProjectDecisionValue.ACTIVE; | ||||
|  | ||||
| import enseirb.myinpulse.model.Entrepreneur; | ||||
| import enseirb.myinpulse.model.Project; | ||||
| import enseirb.myinpulse.model.SectionCell; | ||||
| import enseirb.myinpulse.model.User; | ||||
| import enseirb.myinpulse.service.database.*; | ||||
|  | ||||
| import org.apache.logging.log4j.LogManager; | ||||
| @@ -234,4 +236,49 @@ public class EntrepreneurApiService { | ||||
|     public Iterable<Entrepreneur> getAllEntrepreneurs() { | ||||
|         return entrepreneurService.getAllEntrepreneurs(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Checks if an entrepreneur with the given email has a project that is ACTIVE. | ||||
|      * | ||||
|      * @param email The email of the entrepreneur. | ||||
|      * @return true if the entrepreneur has an active project, false otherwise. | ||||
|      */ | ||||
|     public Boolean checkIfEntrepreneurProjectActive(String email) { | ||||
|         User user = this.userService.getUserByEmail(email); | ||||
|         if (user == null) { | ||||
|             return false; | ||||
|         } | ||||
|         Long userId = user.getIdUser(); | ||||
|  | ||||
|         Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(userId); | ||||
|         if (entrepreneur == null) { | ||||
|             return false; | ||||
|         } | ||||
|         Project proposedProject = entrepreneur.getProjectProposed(); | ||||
|         return proposedProject != null && proposedProject.getProjectStatus() == ACTIVE; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Checks if an entrepreneur with the given email has proposed a project. | ||||
|      * | ||||
|      * @param email The email of the entrepreneur. | ||||
|      * @return true if the entrepreneur has a proposed project, false otherwise. | ||||
|      */ | ||||
|     public Boolean entrepreneurHasPendingRequestedProject(String email) { | ||||
|         User user = this.userService.getUserByEmail(email); | ||||
|         if (user == null) { | ||||
|             return false; | ||||
|         } | ||||
|         Long userId = user.getIdUser(); | ||||
|  | ||||
|         Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(userId); | ||||
|         if (entrepreneur == null) { | ||||
|             return false; | ||||
|         } | ||||
|         Project proposedProject = entrepreneur.getProjectProposed(); | ||||
|         if (entrepreneur.getProjectProposed() == null) { | ||||
|             return false; | ||||
|         } | ||||
|         return proposedProject.getProjectStatus() == PENDING; | ||||
|     } | ||||
| } | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -142,5 +142,56 @@ paths: | ||||
|           description: Bad Request - Invalid input or ID mismatch. | ||||
|         "401": | ||||
|           description: Unauthorized or identity not found | ||||
|         "403": | ||||
|           description: Bad Token - Invalid Keycloack configuration. | ||||
|  | ||||
|  | ||||
|   /entrepreneur/projects/project-is-active: | ||||
|     get: | ||||
|       summary: checks if the project associated with an entrepreneur is active  | ||||
|       description: returns a boolean if the project associated with an entrepreneur has an active status  | ||||
|         (i.e has been validated by an admin). The user should be routed to LeanCanvas. any other response code  | ||||
|         should be treated as false | ||||
|       tags: | ||||
|        - Entrepreneurs API | ||||
|       security: | ||||
|         - MyINPulse: [MyINPulse-entrepreneur] | ||||
|       parameters: | ||||
|       responses: | ||||
|         "200": | ||||
|           description: OK - got the value successfully any other response code should be treated as false. | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
|                 type: boolean | ||||
|         "404": | ||||
|           description: Bad Request - Invalid input or ID mismatch. | ||||
|         "401": | ||||
|           description: Unauthorized or identity not found | ||||
|         "403": | ||||
|           description: Bad Token - Invalid Keycloack configuration. | ||||
|  | ||||
|   /entrepreneur/projects/has-pending-request: | ||||
|     get: | ||||
|       summary: checks if the user has a pending projectRequest  | ||||
|       description: returns a boolean if the project associated with an entrepreneur has a pending status  | ||||
|         (i.e has not yet been validated by an admin). The user should be routed to a page telling him that he should  | ||||
|         wait for admin validation. any other response code should be treated as false. | ||||
|       tags: | ||||
|        - Entrepreneurs API | ||||
|       security: | ||||
|         - MyINPulse: [MyINPulse-entrepreneur] | ||||
|       parameters: | ||||
|       responses: | ||||
|         "200": | ||||
|           description: OK - got the value successfully any other response code should be treated as false. | ||||
|           content: | ||||
|             application/json: | ||||
|               schema: | ||||
|                 type: boolean | ||||
|         "404": | ||||
|           description: Bad Request - Invalid input or ID mismatch. | ||||
|         "401": | ||||
|           description: Unauthorized or identity not found | ||||
|         "403": | ||||
|           description: Bad Token - Invalid Keycloack configuration. | ||||
| @@ -152,4 +152,8 @@ paths: | ||||
|   /entrepreneur/sectionCells: | ||||
|     $ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1sectionCells" | ||||
|   /entrepreneur/sectionCells/{sectionCellId}: | ||||
|     $ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1sectionCells~1{sectionCellId}" | ||||
|     $ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1sectionCells~1{sectionCellId}" | ||||
|   /entrepreneur/projects/project-is-active: | ||||
|     $ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1projects~1project-is-active" | ||||
|   /entrepreneur/projects/has-pending-request: | ||||
|     $ref: "./entrepreneurApi.yaml#/paths/~1entrepreneur~1projects~1has-pending-request" | ||||
		Reference in New Issue
	
	Block a user