mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
import {
|
|
Body, Controller, Delete, Get, HttpCode, HttpStatus,
|
|
Param, ParseUUIDPipe, Patch, Post, Query,
|
|
} from '@nestjs/common';
|
|
import { RuleEngineManage } from '../../../common/rule-engine-guards';
|
|
import { StaffReference } from '../../../common/booking-guards';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { CreateYardDto } from '../dto/create-yard.dto';
|
|
import { ListYardsQueryDto } from '../dto/list-rule-engine-query.dto';
|
|
import { MoveOrderDto } from '../dto/move-order.dto';
|
|
import { ReorderItemsDto } from '../dto/reorder-items.dto';
|
|
import { UpdateYardDto } from '../dto/update-yard.dto';
|
|
import { YardsService } from '../services/yards.service';
|
|
|
|
@ApiTags('yards')
|
|
@Controller('yards')
|
|
@ApiBearerAuth()
|
|
export class YardsController {
|
|
constructor(private readonly service: YardsService) {}
|
|
|
|
@Get()
|
|
// Reference read: every staff form/search needs the yard list (origin /
|
|
// destination pickers), so login is the only requirement.
|
|
@StaffReference()
|
|
@ApiOperation({ summary: 'List yards' })
|
|
findAll(@Query() query: ListYardsQueryDto) {
|
|
return this.service.findAll(query);
|
|
}
|
|
|
|
@Post('reorder')
|
|
@RuleEngineManage('yards')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Bulk reorder yards by ID list' })
|
|
reorder(@Body() dto: ReorderItemsDto) {
|
|
return this.service.reorder(dto);
|
|
}
|
|
|
|
@Post(':id/move-order')
|
|
@RuleEngineManage('yards')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Move a yard up or down in display order' })
|
|
moveOrder(@Param('id', ParseUUIDPipe) id: string, @Body() dto: MoveOrderDto) {
|
|
return this.service.moveOrder(id, dto.direction);
|
|
}
|
|
|
|
@Get(':id')
|
|
@StaffReference()
|
|
@ApiOperation({ summary: 'Get a yard by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.findById(id);
|
|
}
|
|
|
|
@Post()
|
|
@RuleEngineManage('yards')
|
|
@ApiOperation({ summary: 'Create a yard' })
|
|
create(@Body() dto: CreateYardDto) {
|
|
return this.service.create(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@RuleEngineManage('yards')
|
|
@ApiOperation({ summary: 'Update a yard' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateYardDto) {
|
|
return this.service.update(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@RuleEngineManage('yards')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Soft-delete a yard' })
|
|
remove(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.remove(id);
|
|
}
|
|
}
|