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>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Patch,
|
|
Param,
|
|
Body,
|
|
Query,
|
|
UseGuards,
|
|
Request,
|
|
HttpCode,
|
|
HttpStatus,
|
|
ParseUUIDPipe,
|
|
} from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { RolesGuard } from '../../common/guards/roles.guard';
|
|
import { Roles } from '../../common/decorators/roles.decorator';
|
|
import { EmployeesService } from './employees.service';
|
|
import { CreateEmployeeDto } from './dto/create-employee.dto';
|
|
import { QueryEmployeeDto } from './dto/query-employee.dto';
|
|
|
|
interface AuthRequest extends Request {
|
|
user: { id: string; role: string };
|
|
}
|
|
|
|
@Controller('employees')
|
|
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
|
export class EmployeesController {
|
|
constructor(private readonly svc: EmployeesService) {}
|
|
|
|
@Get()
|
|
@Roles('hr_admin', 'hr_specialist', 'manager', 'nursing_director')
|
|
findAll(@Query() query: QueryEmployeeDto, @Request() req: AuthRequest) {
|
|
return this.svc.findAll(query, req.user.id, req.user.role);
|
|
}
|
|
|
|
@Get(':id')
|
|
@Roles('hr_admin', 'hr_specialist', 'manager', 'nursing_director', 'medic_familie')
|
|
findOne(
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Query('reason') reason: string | undefined,
|
|
@Request() req: AuthRequest,
|
|
) {
|
|
return this.svc.findOne(id, req.user.id, req.user.role, reason);
|
|
}
|
|
|
|
@Post()
|
|
@Roles('hr_admin')
|
|
@HttpCode(HttpStatus.CREATED)
|
|
create(@Body() dto: CreateEmployeeDto, @Request() req: AuthRequest) {
|
|
return this.svc.create(dto, req.user.id, req.user.role);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@Roles('hr_admin', 'hr_specialist')
|
|
update(
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Body() dto: Partial<CreateEmployeeDto>,
|
|
@Request() req: AuthRequest,
|
|
) {
|
|
return this.svc.update(id, dto, req.user.id, req.user.role);
|
|
}
|
|
}
|