Class ApplicationController
This controller handles HTTP requests related to job applications, including submitting applications, retrieving application details, updating application status, and generating application statistics. It provides endpoints for both candidates and recruiters based on their roles and permissions.
- Since:
- 2025-05-14
-
Constructor Summary
ConstructorsConstructorDescriptionApplicationController(ApplicationService applicationService) Constructs an ApplicationController with the specified service. -
Method Summary
Modifier and TypeMethodDescriptionaddInterviewNotes(String id, String interviewNotes) Adds or updates the interview notes for a job application.addReviewNotes(String id, String reviewNotes) Adds or updates the review notes for a job application.applyToJob(@Valid ApplicationDto applicationDto) Endpoint for a candidate to apply to a job.Retrieves a specific job application by its ID.getApplicationsByCandidate(String candidateId, int page, int size, String sortBy, String sortDir) Retrieves all applications submitted by a specific candidate.getApplicationsByJob(String jobId, int page, int size, String sortBy, String sortDir) Retrieves all applications for a specific job.getApplicationStats(String jobId) Retrieves statistics for applications to a specific job.updateApplicationStatus(String id, String status, String reviewNotes) Updates the status of a job application.Withdraws a job application.
-
Constructor Details
-
ApplicationController
Constructs an ApplicationController with the specified service.- Parameters:
applicationService- The service for application-related operations
-
-
Method Details
-
applyToJob
@PostMapping @PreAuthorize("hasRole(\'CANDIDATE\')") public ResponseEntity<?> applyToJob(@Valid @RequestBody @Valid ApplicationDto applicationDto) Endpoint for a candidate to apply to a job.This endpoint allows a candidate to submit an application for a specific job. It requires a valid application DTO containing job and candidate information. A candidate can only apply once to each job.
- Parameters:
applicationDto- The DTO containing application details- Returns:
- ResponseEntity with the created application or an error response
-
getApplicationById
@GetMapping("/{id}") @PreAuthorize("hasAnyRole(\'CANDIDATE\', \'RECRUITER\')") public ResponseEntity<?> getApplicationById(@PathVariable String id) Retrieves a specific job application by its ID.This endpoint is accessible to both candidates and recruiters. It returns the application details if found.
- Parameters:
id- The ID of the application to retrieve- Returns:
- ResponseEntity with the application or a not-found status
-
getApplicationsByCandidate
@GetMapping("/candidate/{candidateId}") @PreAuthorize("hasRole(\'CANDIDATE\')") public ResponseEntity<Map<String,Object>> getApplicationsByCandidate(@PathVariable String candidateId, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="applicationDate") String sortBy, @RequestParam(defaultValue="desc") String sortDir) Retrieves all applications submitted by a specific candidate.This endpoint supports pagination and sorting of results. It returns a paginated response with application details.
- Parameters:
candidateId- The ID of the candidatepage- The page number (zero-based)size- The size of each pagesortBy- The field to sort bysortDir- The sort direction (asc or desc)- Returns:
- ResponseEntity with paginated application data
-
getApplicationsByJob
@GetMapping("/job/{jobId}") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<Map<String,Object>> getApplicationsByJob(@PathVariable String jobId, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="applicationDate") String sortBy, @RequestParam(defaultValue="desc") String sortDir) Retrieves all applications for a specific job.This endpoint is accessible to recruiters and supports pagination and sorting. It returns a paginated response with application details for the specified job.
- Parameters:
jobId- The ID of the jobpage- The page number (zero-based)size- The size of each pagesortBy- The field to sort bysortDir- The sort direction (asc or desc)- Returns:
- ResponseEntity with paginated application data
-
updateApplicationStatus
@PutMapping("/{id}/status") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> updateApplicationStatus(@PathVariable String id, @RequestParam String status, @RequestParam(required=false) String reviewNotes) Updates the status of a job application.This endpoint allows recruiters to change the status of an application (e.g., to REVIEWING, SHORTLISTED, REJECTED, or ACCEPTED) and optionally add review notes about the application.
- Parameters:
id- The ID of the application to updatestatus- The new status for the applicationreviewNotes- Optional notes about the application review- Returns:
- ResponseEntity with the updated application or a not-found status
-
addReviewNotes
@PutMapping("/{id}/review") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> addReviewNotes(@PathVariable String id, @RequestParam String reviewNotes) Adds or updates the review notes for a job application.This endpoint allows recruiters to add or modify review notes about an application without changing its status.
- Parameters:
id- The ID of the applicationreviewNotes- The review notes to add or update- Returns:
- ResponseEntity with the updated application or a not-found status
-
addInterviewNotes
@PutMapping("/{id}/interview") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> addInterviewNotes(@PathVariable String id, @RequestParam String interviewNotes) Adds or updates the interview notes for a job application.This endpoint allows recruiters to add or modify notes about an interview conducted with the candidate.
- Parameters:
id- The ID of the applicationinterviewNotes- The interview notes to add or update- Returns:
- ResponseEntity with the updated application or a not-found status
-
withdrawApplication
@DeleteMapping("/{id}") @PreAuthorize("hasRole(\'CANDIDATE\')") public ResponseEntity<?> withdrawApplication(@PathVariable String id) Withdraws a job application.This endpoint allows candidates to withdraw their application for a job, removing it from the system.
- Parameters:
id- The ID of the application to withdraw- Returns:
- ResponseEntity with a success response or a not-found status
-
getApplicationStats
@GetMapping("/stats/job/{jobId}") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> getApplicationStats(@PathVariable String jobId) Retrieves statistics for applications to a specific job.This endpoint provides counts of applications by status (e.g., APPLIED, REVIEWING, SHORTLISTED, REJECTED, ACCEPTED) for a given job.
- Parameters:
jobId- The ID of the job- Returns:
- ResponseEntity with application statistics
-