Files
gongxue-base/apps/server/src/departments/departments.controller.ts
wangziqi 454a0d24c6 fix: release beds/lockers in batchCheckOut
The batchCheckOut method was not releasing assigned beds and lockers
after checkout, leaving them orphaned as 'occupied'. Added the same
release pattern used in checkOut() — using runner.manager.update()
since batchCheckOut operates inside a QueryRunner transaction.
2026-07-09 12:05:36 +08:00

96 lines
2.3 KiB
TypeScript

import {
Controller,
Get,
Post,
Put,
Delete,
Body,
Param,
ParseIntPipe,
UseGuards,
} from '@nestjs/common';
import { DepartmentsService } from './departments.service';
import {
CreateDepartmentDto,
UpdateDepartmentDto,
AssignUserDto,
} from './dto/department.dto';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { RequirePermission } from '../auth/decorators/permission.decorator';
@UseGuards(JwtAuthGuard)
@Controller('departments')
export class DepartmentsController {
constructor(private readonly departmentsService: DepartmentsService) {}
@Get()
@RequirePermission('department:view')
findAll() {
return this.departmentsService.findAll();
}
@Get('tree')
@RequirePermission('department:view')
findTree() {
return this.departmentsService.findTree();
}
/** 获取钉钉同步的部门树,供"从部门创建班级"使用 */
@Get('synced')
@RequirePermission('department:view')
findSyncedTree() {
return this.departmentsService.findSyncedTree();
}
@Get(':id')
@RequirePermission('department:view')
findOne(@Param('id', ParseIntPipe) id: number) {
return this.departmentsService.findOne(id);
}
@Post()
@RequirePermission('department:edit')
create(@Body() dto: CreateDepartmentDto) {
return this.departmentsService.create(dto);
}
@Put(':id')
@RequirePermission('department:edit')
update(
@Param('id', ParseIntPipe) id: number,
@Body() dto: UpdateDepartmentDto,
) {
return this.departmentsService.update(id, dto);
}
@Delete(':id')
@RequirePermission('department:delete')
remove(@Param('id', ParseIntPipe) id: number) {
return this.departmentsService.remove(id);
}
@Get(':id/users')
@RequirePermission('department:view')
getUsers(@Param('id', ParseIntPipe) id: number) {
return this.departmentsService.getUsers(id);
}
@Post(':id/users')
@RequirePermission('department:edit')
assignUser(
@Param('id', ParseIntPipe) id: number,
@Body() dto: AssignUserDto,
) {
return this.departmentsService.assignUser(id, dto);
}
@Delete(':id/users/:userId')
@RequirePermission('department:delete')
removeUser(
@Param('id', ParseIntPipe) id: number,
@Param('userId', ParseIntPipe) userId: number,
) {
return this.departmentsService.removeUser(id, userId);
}
}