All files / src/domains/recruitment recruitment.controller.ts

0% Statements 0/62
0% Branches 0/40
0% Functions 0/20
0% Lines 0/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181                                                                                                                                                                                                                                                                                                                                                                         
import { Controller, Get, Post, Put, Body, Param, Query, UseGuards, Req, Req as Request, HttpStatus, HttpCode, BadRequestException } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { RecruitmentService } from './recruitment.service';
 
@ApiTags('Recruitment')
@Controller('api/v1/recruitment')
export class RecruitmentController {
  constructor(private readonly service: RecruitmentService) {}
 
  @Post('duplicate-candidate-checks/:candidateId')
  @ApiOperation({ summary: 'Run duplicate checks for candidate' })
  async checkDuplicates(@Req() req: any, @Param('candidateId') candidateId: string) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    return this.service.checkDuplicates(tenantId, candidateId);
  }
 
  @Post('applications/:applicationId/transition-stage')
  @ApiOperation({ summary: 'Transition application stage in pipeline' })
  async transitionStage(
    @Req() req: any,
    @Param('applicationId') applicationId: string,
    @Body('targetStageId') targetStageId: string
  ) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    const userId = req.user?.userId || 'system-user';
    return this.service.transitionStage(tenantId, applicationId, targetStageId, userId);
  }
 
  @Post('applications/:applicationId/schedule-interview')
  @ApiOperation({ summary: 'Schedule an interview round' })
  async scheduleInterview(
    @Req() req: any,
    @Param('applicationId') applicationId: string,
    @Body() body: { roundId: string; startAt: string; endAt: string; panelMembers: string[] }
  ) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    return this.service.scheduleInterview(
      tenantId,
      applicationId,
      body.roundId,
      new Date(body.startAt),
      new Date(body.endAt),
      body.panelMembers
    );
  }
 
  @Post('offers')
  @ApiOperation({ summary: 'Create a job offer' })
  async createOffer(@Req() req: any, @Body() body: any) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    return this.service.createOffer(tenantId, body);
  }
 
  @Put('offers/:offerId')
  @ApiOperation({ summary: 'Update a job offer' })
  async updateOffer(@Req() req: any, @Param('offerId') offerId: string, @Body() body: any) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    return this.service.updateOffer(tenantId, offerId, body);
  }
 
  @Post('candidates/:candidateId/handoff')
  @ApiOperation({ summary: 'Hire candidate and trigger HR onboarding handoff' })
  async hireAndHandoff(@Req() req: any, @Param('candidateId') candidateId: string) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    const userId = req.user?.userId || 'system-user';
    return this.service.hireAndHandoff(tenantId, candidateId, userId);
  }
 
  @Get('candidates/:candidateId/ai-summary')
  @ApiOperation({ summary: 'Generate advisory AI candidate summary (redacted)' })
  async getAiSummary(@Req() req: any, @Param('candidateId') candidateId: string) {
    const tenantId = req.headers['x-tenant-id'] || 'tenant-1';
    return this.service.generateAiSummary(tenantId, candidateId);
  }
}
 
@ApiTags('Public Careers')
@Controller('api/v1/public/careers')
export class PublicCareersController {
  constructor(private readonly service: RecruitmentService) {}
 
  @Get('config')
  @ApiOperation({ summary: 'Get careers portal configuration' })
  async getCareersConfig(@Req() req: any) {
    return {
      publicCareersEnabled: true,
      themeBranding: 'modern-emerald',
      consentRequired: true
    };
  }
 
  @Get('jobs')
  @ApiOperation({ summary: 'Get list of published external jobs' })
  async getJobs(@Req() req: any) {
    return [
      {
        jobCode: 'JOB-001',
        title: 'Senior Software Engineer (Go)',
        slug: 'senior-software-engineer-go',
        locations: ['Bengaluru, India', 'Remote'],
        employmentType: 'Full-time'
      }
    ];
  }
 
  @Get('jobs/:slug')
  @ApiOperation({ summary: 'Get job details by slug' })
  async getJobDetails(@Req() req: any, @Param('slug') slug: string) {
    return {
      jobCode: 'JOB-001',
      title: 'Senior Software Engineer (Go)',
      slug: 'senior-software-engineer-go',
      descriptionHtml: '<p>Join our Go experts team.</p>',
      requirementsHtml: '<p>3+ years of experience with Go.</p>',
      locations: ['Bengaluru, India', 'Remote']
    };
  }
 
  @Post('jobs/:id/apply')
  @ApiOperation({ summary: 'Submit application to job posting' })
  async applyToJob(
    @Req() req: any,
    @Param('id') id: string,
    @Body() body: any
  ) {
    // Basic rate limit verification mock for careers submit endpoint
    const clientIp = req.ip || '127.0.0.1';
    this.loggerCheck(clientIp);
 
    return {
      success: true,
      referenceCode: 'APP-REF-998822',
      status: 'submitted'
    };
  }
 
  private loggerCheck(ip: string) {
    // Mock check for rate limiter
  }
}
 
@ApiTags('Mobile Recruitment')
@Controller('api/v1/mobile/recruitment')
export class MobileRecruitmentController {
  constructor(private readonly service: RecruitmentService) {}
 
  @Get('my-schedule')
  @ApiOperation({ summary: 'Get schedule of candidate/interviewer' })
  async getMySchedule(@Req() req: any) {
    return [];
  }
}
 
@ApiTags('Candidate Portal')
@Controller('api/v1/candidate')
export class CandidatePortalController {
  constructor(private readonly service: RecruitmentService) {}
 
  @Get('profile')
  @ApiOperation({ summary: 'Get active candidate profile' })
  async getProfile(@Req() req: any) {
    return {
      firstName: 'Jane',
      lastName: 'Doe',
      email: 'jane.doe@example.com'
    };
  }
}
 
@ApiTags('Agency Recruitment')
@Controller('api/v1/agency/recruitment')
export class AgencyPortalController {
  constructor(private readonly service: RecruitmentService) {}
 
  @Get('assigned-jobs')
  @ApiOperation({ summary: 'Get list of jobs assigned to agency' })
  async getAssignedJobs(@Req() req: any) {
    return [];
  }
}