91 lines
3.8 KiB
TypeScript
91 lines
3.8 KiB
TypeScript
import { Controller, Param, Body, Get, Post, ParseIntPipe, Delete, Patch } from "@nestjs/common";
|
|
|
|
import { SchedulePresetsCreateService } from "src/time-and-attendance/schedule-presets/services/schedule-presets-create.service";
|
|
import { SchedulePresetUpdateService } from "src/time-and-attendance/schedule-presets/services/schedule-presets-update.service";
|
|
import { SchedulePresetDeleteService } from "src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service";
|
|
import { SchedulePresetsGetService } from "src/time-and-attendance/schedule-presets/services/schedule-presets-get.service";
|
|
import { SchedulePresetsDto } from "src/time-and-attendance/schedule-presets/schedule-presets.dto";
|
|
|
|
import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators";
|
|
import { Modules as ModulesEnum } from ".prisma/client";
|
|
import { Access } from "src/common/decorators/module-access.decorators";
|
|
import { SchedulePresetsApplyService } from "src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service";
|
|
|
|
@Controller('schedule-presets')
|
|
export class SchedulePresetsController {
|
|
constructor(
|
|
private readonly getService: SchedulePresetsGetService,
|
|
private readonly createService: SchedulePresetsCreateService,
|
|
private readonly updateService: SchedulePresetUpdateService,
|
|
private readonly deleteService: SchedulePresetDeleteService,
|
|
private readonly applyService: SchedulePresetsApplyService,
|
|
) { }
|
|
|
|
@Get('find-list')
|
|
@ModuleAccessAllowed(ModulesEnum.employee_management)
|
|
async findListById() {
|
|
return this.getService.getSchedulePresets();
|
|
}
|
|
|
|
@Post('create')
|
|
@ModuleAccessAllowed(ModulesEnum.employee_management)
|
|
async createPreset(@Body() dto: SchedulePresetsDto) {
|
|
return await this.createService.createPreset(dto);
|
|
}
|
|
|
|
@Patch('update')
|
|
@ModuleAccessAllowed(ModulesEnum.employee_management)
|
|
async updatePreset(
|
|
@Body() dto: SchedulePresetsDto) {
|
|
return await this.updateService.updatePreset(dto);
|
|
}
|
|
|
|
@Delete('delete/:id')
|
|
@ModuleAccessAllowed(ModulesEnum.employee_management)
|
|
async deletePreset(
|
|
@Param('id') id: number) {
|
|
return await this.deleteService.deletePreset(id);
|
|
}
|
|
|
|
@Post('apply-preset')
|
|
@ModuleAccessAllowed(ModulesEnum.timesheets)
|
|
async applyPresetToTimesheet(
|
|
@Access('email') email: string,
|
|
@Body('timesheet_id') timesheet_id: number,
|
|
) {
|
|
return await this.applyService.applyPresetToTimesheet(email, timesheet_id);
|
|
}
|
|
|
|
@Post('apply-preset/:email')
|
|
@ModuleAccessAllowed(ModulesEnum.timesheets_approval)
|
|
async applyPresetToTimesheetFromApproval(
|
|
@Access('email') email: string,
|
|
@Body('timesheet_id') timesheet_id: number,
|
|
@Param('email') employee_email: string,
|
|
) {
|
|
return await this.applyService.applyPresetToTimesheet(email, timesheet_id, employee_email);
|
|
}
|
|
|
|
@Post('apply-day-preset')
|
|
@ModuleAccessAllowed(ModulesEnum.timesheets)
|
|
async applyPresetToDay(
|
|
@Access('email') email: string,
|
|
@Body('timesheet_id') timesheet_id: number,
|
|
@Body('week_day_index') week_day_index: number,
|
|
@Body('date') date: string,
|
|
) {
|
|
return await this.applyService.applyPresetToDay(email, timesheet_id, week_day_index, date);
|
|
}
|
|
|
|
@Post('apply-day-preset/:email')
|
|
@ModuleAccessAllowed(ModulesEnum.timesheets_approval)
|
|
async applyPresetToDayFromApproval(
|
|
@Access('email') email: string,
|
|
@Body('timesheet_id') timesheet_id: number,
|
|
@Body('week_day_index') week_day_index: number,
|
|
@Body('date') date: string,
|
|
@Param('email') employee_email: string,
|
|
) {
|
|
return await this.applyService.applyPresetToDay(email, timesheet_id, week_day_index, date, employee_email);
|
|
}
|
|
} |