refactor(server): 清理无用导入与类型转换
- 移除测试/控制器中未使用的导入与实例 - bills/classroom-rentals 改用 ESM 导入替代 require - bills.service 去掉多余断言、backfill 显式转字符串、main.ts void bootstrap
This commit is contained in:
@@ -24,7 +24,7 @@ import type { AuthenticatedUser } from '../authorization';
|
|||||||
import { AiAttachmentService } from './ai-attachment.service';
|
import { AiAttachmentService } from './ai-attachment.service';
|
||||||
import { AiChatService } from './ai-chat.service';
|
import { AiChatService } from './ai-chat.service';
|
||||||
import type { AiSseEventName } from './ai-chat.types';
|
import type { AiSseEventName } from './ai-chat.types';
|
||||||
import type { AiReviewSection, AiReviewSectionType } from './entities';
|
import type { AiReviewSectionType } from './entities';
|
||||||
import {
|
import {
|
||||||
CreateConversationDto,
|
CreateConversationDto,
|
||||||
EditMessageDto,
|
EditMessageDto,
|
||||||
@@ -248,7 +248,7 @@ export class AiChatController {
|
|||||||
data: await this.service.confirmReviewStep(
|
data: await this.service.confirmReviewStep(
|
||||||
req.user,
|
req.user,
|
||||||
reviewId,
|
reviewId,
|
||||||
sectionKey as AiReviewSection['key'],
|
sectionKey,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,4 @@
|
|||||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||||
import { DataSource } from 'typeorm';
|
|
||||||
import * as allEntities from '../entities';
|
|
||||||
import { Bed } from '../entities/bed.entity';
|
|
||||||
import { Occupancy } from '../entities/occupancy.entity';
|
|
||||||
import { Organization } from '../entities/organization.entity';
|
|
||||||
import { Room } from '../entities/room.entity';
|
|
||||||
import { Student } from '../entities/student.entity';
|
|
||||||
import { AiConversation } from './entities/ai-conversation.entity';
|
|
||||||
import { AiMessage } from './entities/ai-message.entity';
|
|
||||||
import { AiReview } from './entities/ai-review.entity';
|
|
||||||
import { User } from '../entities/user.entity';
|
|
||||||
import { AiReviewService } from './ai-review.service';
|
import { AiReviewService } from './ai-review.service';
|
||||||
import type { ExcelSheetRows } from './ai-excel-reader.service';
|
import type { ExcelSheetRows } from './ai-excel-reader.service';
|
||||||
|
|
||||||
@@ -636,4 +625,3 @@ describe('AiReviewService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,24 +23,10 @@ describe('AttendanceRecordsController — DingTalk import scope', () => {
|
|||||||
can: jest.fn().mockReturnValue(false),
|
can: jest.fn().mockReturnValue(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
let controller: AttendanceController;
|
|
||||||
let recordsController: AttendanceRecordsController;
|
|
||||||
let importController: AttendanceImportController;
|
let importController: AttendanceImportController;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
controller = new AttendanceController(
|
|
||||||
attendanceService as unknown as AttendanceService,
|
|
||||||
importService as unknown as AttendanceImportService,
|
|
||||||
logService as unknown as OperationLogsService,
|
|
||||||
authzService as never,
|
|
||||||
);
|
|
||||||
recordsController = new AttendanceRecordsController(
|
|
||||||
attendanceService as unknown as AttendanceService,
|
|
||||||
importService as unknown as AttendanceImportService,
|
|
||||||
logService as unknown as OperationLogsService,
|
|
||||||
authzService as never,
|
|
||||||
);
|
|
||||||
importController = new AttendanceImportController(
|
importController = new AttendanceImportController(
|
||||||
attendanceService as unknown as AttendanceService,
|
attendanceService as unknown as AttendanceService,
|
||||||
importService as unknown as AttendanceImportService,
|
importService as unknown as AttendanceImportService,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Deposit } from '../entities/deposit.entity';
|
|||||||
import * as ExcelJS from 'exceljs';
|
import * as ExcelJS from 'exceljs';
|
||||||
import * as PDFDocument from 'pdfkit';
|
import * as PDFDocument from 'pdfkit';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BillsExportService {
|
export class BillsExportService {
|
||||||
@@ -149,7 +150,6 @@ export class BillsExportService {
|
|||||||
'/usr/share/fonts/truetype/wqy/wqy-microhei.ttc',
|
'/usr/share/fonts/truetype/wqy/wqy-microhei.ttc',
|
||||||
];
|
];
|
||||||
let fontRegistered = false;
|
let fontRegistered = false;
|
||||||
const fs = require('fs');
|
|
||||||
for (const fp of fontPaths) {
|
for (const fp of fontPaths) {
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(fp)) {
|
if (fs.existsSync(fp)) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export class BillsService {
|
|||||||
*/
|
*/
|
||||||
async generateBills(dto: GenerateBillsDto) {
|
async generateBills(dto: GenerateBillsDto) {
|
||||||
const { operationId, ...request } = dto;
|
const { operationId, ...request } = dto;
|
||||||
const work = () => this.generation.generateBillsOnce(request as GenerateBillsDto);
|
const work = () => this.generation.generateBillsOnce(request);
|
||||||
return this.financialOperations
|
return this.financialOperations
|
||||||
? this.financialOperations.run(operationId, 'bill.generate', work)
|
? this.financialOperations.run(operationId, 'bill.generate', work)
|
||||||
: work();
|
: work();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { RentalScheduleService } from './rental-schedule.service';
|
|||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import { randomBytes } from 'crypto';
|
||||||
|
|
||||||
// 预设色板(与 organizations.service 保持一致,作为颜色兜底)
|
// 预设色板(与 organizations.service 保持一致,作为颜色兜底)
|
||||||
function rentalConflictError(
|
function rentalConflictError(
|
||||||
@@ -347,7 +348,7 @@ export class ClassroomRentalsService {
|
|||||||
const ext = path.extname(file.originalname).toLowerCase();
|
const ext = path.extname(file.originalname).toLowerCase();
|
||||||
if (ext !== '.pdf') throw new BadRequestException('文件扩展名必须为 .pdf');
|
if (ext !== '.pdf') throw new BadRequestException('文件扩展名必须为 .pdf');
|
||||||
// UUID 文件名
|
// UUID 文件名
|
||||||
const uuid = require('crypto').randomBytes(16).toString('hex');
|
const uuid = randomBytes(16).toString('hex');
|
||||||
const filename = `${uuid}.pdf`;
|
const filename = `${uuid}.pdf`;
|
||||||
const fullPath = path.join(this.uploadDir, filename);
|
const fullPath = path.join(this.uploadDir, filename);
|
||||||
// 路径遍历防护
|
// 路径遍历防护
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export async function backfillOrganizations(
|
|||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)`,
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)`,
|
||||||
[
|
[
|
||||||
uuidV7(),
|
uuidV7(),
|
||||||
`ORG_${legacy.id}`,
|
`ORG_${String(legacy.id)}`,
|
||||||
name,
|
name,
|
||||||
0,
|
0,
|
||||||
legacy.contact || null,
|
legacy.contact || null,
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ async function bootstrap() {
|
|||||||
|
|
||||||
await app.listen(process.env.PORT ?? 3000);
|
await app.listen(process.env.PORT ?? 3000);
|
||||||
}
|
}
|
||||||
bootstrap();
|
void bootstrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user