"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecruitmentController = void 0;
const common_1 = require("@nestjs/common");
const permission_request_util_1 = require("../../common/access-control/permission-request.util");
const current_user_decorator_1 = require("../../common/decorators/current-user.decorator");
const zod_validation_pipe_1 = require("../../common/pipes/zod-validation.pipe");
const jwt_guard_1 = require("../owner/guards/jwt.guard");
const recruitment_dto_1 = require("./recruitment.dto");
const recruitment_service_1 = require("./recruitment.service");
let RecruitmentController = class RecruitmentController {
    constructor(service) {
        this.service = service;
    }
    async createJobPosting(data, owner_id, req, res) {
        const result = await this.service.createJobPosting(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async getJobPostings(query, owner_id, req, res) {
        const result = await this.service.getJobPostings(query, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async getJobPostingById(id, owner_id, req, res) {
        const result = await this.service.getJobPostingById(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async updateJobPosting(id, data, owner_id, req, res) {
        const result = await this.service.updateJobPosting(id, data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async deleteJobPosting(id, owner_id, req, res) {
        const result = await this.service.deleteJobPosting(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async createApplication(data, owner_id, req, res) {
        console.log(data);
        const result = await this.service.createApplication(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async getApplications(query, owner_id, req, res) {
        const result = await this.service.getApplications(query, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async getApplicationById(id, owner_id, req, res) {
        const result = await this.service.getApplicationById(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async updateApplication(id, data, owner_id, req, res) {
        const result = await this.service.updateApplication(id, data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async updateApplicationStatus(id, data, owner_id, req, res) {
        const result = await this.service.updateApplicationStatus(id, data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async bulkUpdateApplicationStatus(data, owner_id, req, res) {
        const result = await this.service.bulkUpdateApplicationStatus(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async deleteApplication(id, owner_id, req, res) {
        const result = await this.service.deleteApplication(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async createTask(data, owner_id, req, res) {
        const result = await this.service.createTask(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async updateTask(id, data, owner_id, req, res) {
        const result = await this.service.updateTask(id, data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async deleteTask(id, owner_id, req, res) {
        const result = await this.service.deleteTask(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async assignBulkTasks(data, owner_id, req, res) {
        const result = await this.service.assignBulkTasks(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async getTasks(query, owner_id, req, res) {
        const result = await this.service.getTasks(query, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async sendTaskEmail(id, owner_id, req, res) {
        const result = await this.service.sendTaskEmail(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async getStats(owner_id, req, res) {
        const result = await this.service.getStats(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async createApiKey(data, owner_id, req, res) {
        const result = await this.service.createApiKey(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async listApiKeys(owner_id, req, res) {
        const result = await this.service.listApiKeys(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async revokeApiKey(id, owner_id, req, res) {
        const result = await this.service.revokeApiKey(id, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async scheduleInterview(data, owner_id, req, res) {
        const result = await this.service.scheduleInterview(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
    async cancelInterview(data, owner_id, req, res) {
        const result = await this.service.cancelInterview(data, owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(result.status).json(result);
    }
};
exports.RecruitmentController = RecruitmentController;
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.createJobPostingSchema)),
    (0, common_1.Post)('job-postings/create'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "createJobPosting", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.jobPostingFilterSchema)),
    (0, common_1.Get)('job-postings/filter'),
    __param(0, (0, common_1.Query)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "getJobPostings", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('job-postings/find/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "getJobPostingById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.updateJobPostingSchema)),
    (0, common_1.Patch)('job-postings/update/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "updateJobPosting", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Delete)('job-postings/delete/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "deleteJobPosting", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.createJobApplicationSchema)),
    (0, common_1.Post)('job-applications/create'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "createApplication", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.jobApplicationFilterSchema)),
    (0, common_1.Get)('job-applications/filter'),
    __param(0, (0, common_1.Query)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "getApplications", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('job-applications/find/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "getApplicationById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.updateJobApplicationSchema)),
    (0, common_1.Patch)('job-applications/update/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "updateApplication", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.updateApplicationStatusSchema)),
    (0, common_1.Patch)('job-applications/update-status/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "updateApplicationStatus", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.bulkUpdateApplicationStatusSchema)),
    (0, common_1.Patch)('job-applications/bulk-update-status'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "bulkUpdateApplicationStatus", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Delete)('job-applications/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "deleteApplication", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.createRecruitmentTaskSchema)),
    (0, common_1.Post)('recruitment-tasks/create'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "createTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.updateRecruitmentTaskSchema)),
    (0, common_1.Patch)('recruitment-tasks/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "updateTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Delete)('recruitment-tasks/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "deleteTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.assignRecruitmentTasksSchema)),
    (0, common_1.Post)('recruitment-tasks/assign-bulk'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "assignBulkTasks", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.recruitmentTaskFilterSchema)),
    (0, common_1.Get)('recruitment-tasks/filter'),
    __param(0, (0, common_1.Query)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "getTasks", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Post)('recruitment-tasks/send-email/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "sendTaskEmail", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('recruitment/stats'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "getStats", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.createTenantApiKeySchema)),
    (0, common_1.Post)('tenant-api-keys/create'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "createApiKey", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('tenant-api-keys/all'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "listApiKeys", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Delete)('tenant-api-keys/revoke/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "revokeApiKey", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.scheduleInterviewSchema)),
    (0, common_1.Post)('job-applications/schedule-interview'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "scheduleInterview", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(recruitment_dto_1.cancelInterviewSchema)),
    (0, common_1.Post)('job-applications/cancel-interview'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], RecruitmentController.prototype, "cancelInterview", null);
exports.RecruitmentController = RecruitmentController = __decorate([
    (0, common_1.Controller)(),
    __metadata("design:paramtypes", [recruitment_service_1.RecruitmentService])
], RecruitmentController);
//# sourceMappingURL=recruitment.controller.js.map