feat: 为批量归档补充批量恢复
This commit is contained in:
@@ -13,6 +13,8 @@ import {
|
||||
UseInterceptors,
|
||||
UploadedFile,
|
||||
BadRequestException,
|
||||
UsePipes,
|
||||
ValidationPipe,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
@@ -27,6 +29,7 @@ import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { OperationLogsService } from '../operation-logs/operation-logs.service';
|
||||
import { extractRequestInfo } from '../common/request-utils';
|
||||
import { RequirePermission } from '../auth/decorators/permission.decorator';
|
||||
import { BatchIdsDto } from '../common/batch-ids.dto';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
import {
|
||||
createOccupancyImportTemplateWorkbook,
|
||||
@@ -49,14 +52,34 @@ export class OccupanciesController {
|
||||
@Query('roomId') roomId?: string,
|
||||
@Query('studentId') studentId?: string,
|
||||
@Query('active') active?: string,
|
||||
@Query('status') status?: 'active' | 'archived',
|
||||
) {
|
||||
return this.service.findAll({
|
||||
roomId: roomId ? +roomId : undefined,
|
||||
studentId: studentId ? +studentId : undefined,
|
||||
active: active === 'true',
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
@Put('batch-restore')
|
||||
@RequirePermission('occupancy:delete')
|
||||
@UsePipes(new ValidationPipe({ transform: true, whitelist: true, forbidNonWhitelisted: true }))
|
||||
async batchRestore(@Body() dto: BatchIdsDto, @Request() req: any) {
|
||||
const { ipAddress, userAgent } = extractRequestInfo(req);
|
||||
const result = await this.service.batchRestore(dto.ids);
|
||||
await this.logService.log({
|
||||
userId: req.user?.id,
|
||||
username: req.user?.username,
|
||||
module: '入住管理',
|
||||
action: '批量恢复入住记录',
|
||||
detail: `IDs: ${dto.ids.join(',')}`,
|
||||
ipAddress,
|
||||
userAgent,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Post('batch-check-out')
|
||||
@RequirePermission('occupancy:checkout')
|
||||
async batchCheckOut(@Body() dto: BatchCheckOutDto, @Request() req: any) {
|
||||
|
||||
Reference in New Issue
Block a user