feat: add Bed and Locker REST routes to RoomsController
This commit is contained in:
@@ -17,6 +17,8 @@ import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import type { Response } from 'express';
|
||||
import { RoomsService } from './rooms.service';
|
||||
import { CreateRoomDto, UpdateRoomDto } from './dto/room.dto';
|
||||
import { CreateBedDto, UpdateBedDto, BatchCreateBedDto } from './dto/bed.dto';
|
||||
import { CreateLockerDto, UpdateLockerDto, BatchCreateLockerDto } from './dto/locker.dto';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { OperationLogsService } from '../operation-logs/operation-logs.service';
|
||||
import { extractRequestInfo } from '../common/request-utils';
|
||||
@@ -144,6 +146,89 @@ export class RoomsController {
|
||||
res!.end();
|
||||
}
|
||||
|
||||
// ── 床位管理 ──
|
||||
|
||||
@Get(':roomId/beds')
|
||||
@RequirePermission('room:view')
|
||||
getBeds(@Param('roomId') roomId: string) {
|
||||
return this.service.getRoomBeds(+roomId);
|
||||
}
|
||||
|
||||
@Get(':roomId/beds/available')
|
||||
@RequirePermission('room:view')
|
||||
getAvailableBeds(@Param('roomId') roomId: string) {
|
||||
return this.service.getRoomAvailableBeds(+roomId);
|
||||
}
|
||||
|
||||
@Post(':roomId/beds')
|
||||
@RequirePermission('room:edit')
|
||||
createBed(@Param('roomId') roomId: string, @Body() dto: CreateBedDto) {
|
||||
return this.service.createBed(+roomId, dto);
|
||||
}
|
||||
|
||||
@Put(':roomId/beds/:id')
|
||||
@RequirePermission('room:edit')
|
||||
updateBed(
|
||||
@Param('roomId') roomId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateBedDto,
|
||||
) {
|
||||
return this.service.updateBed(+roomId, +id, dto);
|
||||
}
|
||||
|
||||
@Delete(':roomId/beds/:id')
|
||||
@RequirePermission('room:edit')
|
||||
deleteBed(@Param('roomId') roomId: string, @Param('id') id: string) {
|
||||
return this.service.deleteBed(+roomId, +id);
|
||||
}
|
||||
|
||||
@Post(':roomId/beds/batch')
|
||||
@RequirePermission('room:edit')
|
||||
batchCreateBeds(@Param('roomId') roomId: string, @Body() dto: BatchCreateBedDto) {
|
||||
return this.service.batchCreateBeds(+roomId, dto);
|
||||
}
|
||||
|
||||
// ── 柜子管理 ──
|
||||
|
||||
@Get(':roomId/lockers')
|
||||
@RequirePermission('room:view')
|
||||
getLockers(@Param('roomId') roomId: string) {
|
||||
return this.service.getRoomLockers(+roomId);
|
||||
}
|
||||
|
||||
@Get(':roomId/lockers/available')
|
||||
@RequirePermission('room:view')
|
||||
getAvailableLockers(@Param('roomId') roomId: string) {
|
||||
return this.service.getRoomAvailableLockers(+roomId);
|
||||
}
|
||||
|
||||
@Post(':roomId/lockers')
|
||||
@RequirePermission('room:edit')
|
||||
createLocker(@Param('roomId') roomId: string, @Body() dto: CreateLockerDto) {
|
||||
return this.service.createLocker(+roomId, dto);
|
||||
}
|
||||
|
||||
@Put(':roomId/lockers/:id')
|
||||
@RequirePermission('room:edit')
|
||||
updateLocker(
|
||||
@Param('roomId') roomId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateLockerDto,
|
||||
) {
|
||||
return this.service.updateLocker(+roomId, +id, dto);
|
||||
}
|
||||
|
||||
@Delete(':roomId/lockers/:id')
|
||||
@RequirePermission('room:edit')
|
||||
deleteLocker(@Param('roomId') roomId: string, @Param('id') id: string) {
|
||||
return this.service.deleteLocker(+roomId, +id);
|
||||
}
|
||||
|
||||
@Post(':roomId/lockers/batch')
|
||||
@RequirePermission('room:edit')
|
||||
batchCreateLockers(@Param('roomId') roomId: string, @Body() dto: BatchCreateLockerDto) {
|
||||
return this.service.batchCreateLockers(+roomId, dto);
|
||||
}
|
||||
@Get(':id')
|
||||
@RequirePermission('room:view')
|
||||
findOne(@Param('id') id: string) {
|
||||
|
||||
Reference in New Issue
Block a user