33800292aa
- apps/api/Dockerfile: build NestJS, run prisma migrate deploy on start - apps/web/Dockerfile + nginx.conf: build Vite, serve static, proxy /api -> api - docker-compose.coolify.yml: full prod stack (postgres, redis, minio, keycloak, api, web) - .dockerignore / .gitignore / .gitattributes Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
84 lines
2.7 KiB
TypeScript
84 lines
2.7 KiB
TypeScript
import {
|
|
Controller, Get, Post, Patch, Delete, Body, Param,
|
|
ParseUUIDPipe, UseGuards, Request, HttpCode, HttpStatus,
|
|
} from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { RolesGuard } from '../../../common/guards/roles.guard';
|
|
import { Roles } from '../../../common/decorators/roles.decorator';
|
|
import { ContractsService } from './contracts.service';
|
|
import { CreateContractDto } from './create-contract.dto';
|
|
|
|
interface AuthReq extends Request { user: { id: string; role: string } }
|
|
|
|
@Controller('employees/:employeeId/contracts')
|
|
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
|
export class ContractsController {
|
|
constructor(private readonly svc: ContractsService) {}
|
|
|
|
@Get()
|
|
@Roles('hr_admin', 'hr_specialist', 'manager', 'nursing_director', 'quality_auditor', 'employee')
|
|
findAll(@Param('employeeId', ParseUUIDPipe) employeeId: string) {
|
|
return this.svc.findAll(employeeId);
|
|
}
|
|
|
|
/** MAX(zile_concediu) across all CIM of this employee */
|
|
@Get('zile-concediu-max')
|
|
@Roles('hr_admin', 'hr_specialist', 'manager', 'nursing_director', 'quality_auditor', 'employee')
|
|
getMaxZileConcediu(@Param('employeeId', ParseUUIDPipe) employeeId: string) {
|
|
return this.svc.getMaxZileConcediu(employeeId);
|
|
}
|
|
|
|
@Get(':id')
|
|
@Roles('hr_admin', 'hr_specialist', 'manager', 'nursing_director', 'quality_auditor', 'employee')
|
|
findOne(
|
|
@Param('employeeId', ParseUUIDPipe) employeeId: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
) {
|
|
return this.svc.findOne(employeeId, id);
|
|
}
|
|
|
|
@Post()
|
|
@Roles('hr_admin', 'hr_specialist')
|
|
@HttpCode(HttpStatus.CREATED)
|
|
create(
|
|
@Param('employeeId', ParseUUIDPipe) employeeId: string,
|
|
@Body() dto: CreateContractDto,
|
|
@Request() req: AuthReq,
|
|
) {
|
|
return this.svc.create(employeeId, dto, req.user.id, req.user.role);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@Roles('hr_admin', 'hr_specialist')
|
|
update(
|
|
@Param('employeeId', ParseUUIDPipe) employeeId: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Body() dto: Partial<CreateContractDto>,
|
|
@Request() req: AuthReq,
|
|
) {
|
|
return this.svc.update(employeeId, id, dto, req.user.id, req.user.role);
|
|
}
|
|
|
|
@Patch(':id/terminate')
|
|
@Roles('hr_admin', 'hr_specialist')
|
|
terminate(
|
|
@Param('employeeId', ParseUUIDPipe) employeeId: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Body('dataDemisiei') dataDemisiei: string,
|
|
@Request() req: AuthReq,
|
|
) {
|
|
return this.svc.terminate(employeeId, id, dataDemisiei, req.user.id, req.user.role);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@Roles('hr_admin')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
remove(
|
|
@Param('employeeId', ParseUUIDPipe) employeeId: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Request() req: AuthReq,
|
|
) {
|
|
return this.svc.remove(employeeId, id, req.user.id, req.user.role);
|
|
}
|
|
}
|