feat: add generated code

This commit is contained in:
aid-orchestrator
2026-04-23 07:57:21 +00:00
parent 636fca2c3a
commit fedb5f1841
24 changed files with 656 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
Query,
UseGuards,
} from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { EquipmentService } from './equipment.service';
import { CreateEquipmentDto } from './dto/create-equipment.dto';
import { UpdateEquipmentDto } from './dto/update-equipment.dto';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
const parseJson = <T>(value?: string): T | undefined => {
if (!value) return undefined;
try {
return JSON.parse(value) as T;
} catch {
return undefined;
}
};
@ApiTags('equipment')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('equipment')
export class EquipmentController {
constructor(private readonly equipmentService: EquipmentService) {}
@Get()
findAll(
@Query('skip') skip?: string,
@Query('take') take?: string,
@Query('orderBy') orderBy?: string,
@Query('where') where?: string,
) {
return this.equipmentService.findAll({
skip: skip ? Number(skip) : 0,
take: take ? Number(take) : 25,
orderBy: parseJson(orderBy),
where: parseJson(where),
});
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.equipmentService.findOne({ id });
}
@Post()
create(@Body() dto: CreateEquipmentDto) {
return this.equipmentService.create(dto);
}
@Patch(':id')
update(@Param('id') id: string, @Body() dto: UpdateEquipmentDto) {
return this.equipmentService.update({ where: { id }, data: dto });
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.equipmentService.remove({ id });
}
}