Class RecruiterController

java.lang.Object
me.josephsf.jobportaljosephsfeir.controller.RecruiterController

@CrossOrigin(origins="*", maxAge=3600L) @RestController @RequestMapping("/api/recruiters") public class RecruiterController extends Object
REST controller for managing recruiter profiles in the Job Portal system.

This controller handles HTTP requests related to recruiter profiles, including creating, retrieving, updating, and deleting recruiter information. It also provides endpoints for searching recruiters by various criteria such as company name and location. Additional functionality includes recruiter verification by administrators and retrieving recruiter statistics.

Most operations in this controller require either RECRUITER or ADMIN role authorization, with certain operations like verification restricted to administrators only.

Since:
2025-05-14
  • Constructor Details

    • RecruiterController

      public RecruiterController(RecruiterService recruiterService)
      Constructs a RecruiterController with the specified service.
      Parameters:
      recruiterService - The service for recruiter-related operations
  • Method Details

    • getRecruiterById

      @GetMapping("/{id}") @PreAuthorize("hasAnyRole(\'RECRUITER\', \'ADMIN\')") public ResponseEntity<?> getRecruiterById(@PathVariable String id)
      Retrieves a recruiter profile by its ID.

      This endpoint is accessible to recruiters and administrators. It returns the recruiter's profile information if found.

      Parameters:
      id - The ID of the recruiter profile to retrieve
      Returns:
      ResponseEntity with the recruiter profile or a not-found status
    • getRecruiterByUserId

      @GetMapping("/user/{userId}") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> getRecruiterByUserId(@PathVariable String userId)
      Retrieves a recruiter profile by the associated user ID.

      This endpoint allows recruiters to access their own profile by their user ID. It is primarily used for profile setup and management.

      Parameters:
      userId - The ID of the user associated with the recruiter profile
      Returns:
      ResponseEntity with the recruiter profile or a not-found status
    • createRecruiterProfile

      @PostMapping @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> createRecruiterProfile(@Valid @RequestBody @Valid RecruiterDto recruiterDto)
      Creates a new recruiter profile.

      This endpoint allows users with the RECRUITER role to create their profile by providing company and professional information. A user can only have one recruiter profile.

      Parameters:
      recruiterDto - The DTO containing recruiter profile information
      Returns:
      ResponseEntity with the created profile or an error response
    • updateRecruiterProfile

      @PutMapping("/{id}") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> updateRecruiterProfile(@PathVariable String id, @Valid @RequestBody @Valid RecruiterDto recruiterDto)
      Updates an existing recruiter profile.

      This endpoint allows recruiters to update their profile information such as company details, contact information, and professional description.

      Parameters:
      id - The ID of the recruiter profile to update
      recruiterDto - The DTO containing updated profile information
      Returns:
      ResponseEntity with the updated profile or a not-found status
    • deleteRecruiterProfile

      @DeleteMapping("/{id}") @PreAuthorize("hasAnyRole(\'RECRUITER\', \'ADMIN\')") public ResponseEntity<?> deleteRecruiterProfile(@PathVariable String id)
      Deletes a recruiter profile.

      This endpoint allows recruiters to delete their own profile or administrators to delete any recruiter profile.

      Parameters:
      id - The ID of the recruiter profile to delete
      Returns:
      ResponseEntity with a success response or a not-found status
    • getRecruitersByCompany

      @GetMapping("/company/{companyName}") @PreAuthorize("hasAnyRole(\'RECRUITER\', \'ADMIN\')") public ResponseEntity<?> getRecruitersByCompany(@PathVariable String companyName)
      Retrieves recruiters by company name.

      This endpoint allows recruiters and administrators to find all recruiters associated with a specific company.

      Parameters:
      companyName - The name of the company to search for
      Returns:
      ResponseEntity with a list of recruiters from the specified company
    • searchRecruiters

      @GetMapping("/search") @PreAuthorize("hasAnyRole(\'RECRUITER\', \'ADMIN\')") public ResponseEntity<?> searchRecruiters(@RequestParam(required=false) String companyName, @RequestParam(required=false) String location, @RequestParam(required=false) String industry)
      Searches for recruiters based on multiple criteria.

      This endpoint allows recruiters and administrators to search for recruiters based on company name, location, and industry. All parameters are optional and can be combined for more specific searches.

      Parameters:
      companyName - The company name to search for
      location - The location to search for
      industry - The industry to search for
      Returns:
      ResponseEntity with a list of matching recruiters
    • verifyRecruiter

      @PutMapping("/{id}/verify") @PreAuthorize("hasRole(\'ADMIN\')") public ResponseEntity<?> verifyRecruiter(@PathVariable String id)
      Verifies a recruiter profile.

      This endpoint allows administrators to verify recruiter profiles, which can provide additional credibility and visibility to verified recruiters. Only users with the ADMIN role can perform this operation.

      Parameters:
      id - The ID of the recruiter profile to verify
      Returns:
      ResponseEntity with the updated recruiter profile or a not-found status
    • getVerifiedRecruiters

      @GetMapping("/verified") @PreAuthorize("hasAnyRole(\'RECRUITER\', \'ADMIN\')") public ResponseEntity<?> getVerifiedRecruiters()
      Retrieves all verified recruiter profiles.

      This endpoint allows recruiters and administrators to view all recruiter profiles that have been verified by administrators.

      Returns:
      ResponseEntity with a list of verified recruiters
    • getRecruiterStats

      @GetMapping("/{id}/stats") @PreAuthorize("hasRole(\'RECRUITER\')") public ResponseEntity<?> getRecruiterStats(@PathVariable String id)
      Retrieves statistics about a recruiter's profile and job postings.

      This endpoint provides statistical information about a recruiter's job posting history, including counts of active jobs, applications received, and other recruitment metrics.

      Parameters:
      id - The ID of the recruiter profile
      Returns:
      ResponseEntity with statistical information about the recruiter