feat: 完成PHP到NestJS的100%功能迁移

- 迁移25个模块,包含95个控制器和160个服务
- 新增验证码管理、登录配置、云编译等模块
- 完善认证授权、会员管理、支付系统等核心功能
- 实现完整的队列系统、配置管理、监控体系
- 确保100%功能对齐和命名一致性
- 支持生产环境部署
This commit is contained in:
万物街
2025-09-10 08:04:28 +08:00
parent a2d6a47601
commit 7a20a0c50a
551 changed files with 35628 additions and 2025 deletions

View File

@@ -65,7 +65,9 @@ describe('PerformanceMonitorService', () => {
expect(result).toEqual(mockSlowQueries);
expect(mockQueryRunner.query).toHaveBeenCalledWith(
expect.stringContaining('performance_schema.events_statements_summary_by_digest'),
expect.stringContaining(
'performance_schema.events_statements_summary_by_digest',
),
);
});
@@ -196,7 +198,9 @@ describe('PerformanceMonitorService', () => {
},
];
jest.spyOn(service, 'getQueryExecutionPlan').mockResolvedValue(mockExecutionPlan);
jest
.spyOn(service, 'getQueryExecutionPlan')
.mockResolvedValue(mockExecutionPlan);
const sql = 'SELECT * FROM member WHERE status = 1';
const result = await service.analyzeQueryPerformance(sql);
@@ -224,14 +228,18 @@ describe('PerformanceMonitorService', () => {
},
];
jest.spyOn(service, 'getQueryExecutionPlan').mockResolvedValue(mockExecutionPlan);
jest
.spyOn(service, 'getQueryExecutionPlan')
.mockResolvedValue(mockExecutionPlan);
const sql = 'SELECT * FROM member WHERE name LIKE "%test%"';
const result = await service.analyzeQueryPerformance(sql);
expect(result.analysis.hasFullTableScan).toBe(true);
expect(result.analysis.usesIndex).toBe(false);
expect(result.recommendations).toContain('查询执行了全表扫描,建议添加适当的索引');
expect(result.recommendations).toContain(
'查询执行了全表扫描,建议添加适当的索引',
);
});
});
@@ -300,11 +308,21 @@ describe('PerformanceMonitorService', () => {
describe('performanceCheck', () => {
it('should perform complete performance check', async () => {
const checkSlowQueriesSpy = jest.spyOn(service, 'checkSlowQueries').mockResolvedValue([]);
const checkTableSizesSpy = jest.spyOn(service, 'checkTableSizes').mockResolvedValue([]);
const checkIndexEfficiencySpy = jest.spyOn(service, 'checkIndexEfficiency').mockResolvedValue([]);
const getConnectionStatusSpy = jest.spyOn(service, 'getConnectionStatus').mockResolvedValue({});
const getPerformanceMetricsSpy = jest.spyOn(service, 'getPerformanceMetrics').mockResolvedValue({});
const checkSlowQueriesSpy = jest
.spyOn(service, 'checkSlowQueries')
.mockResolvedValue([]);
const checkTableSizesSpy = jest
.spyOn(service, 'checkTableSizes')
.mockResolvedValue([]);
const checkIndexEfficiencySpy = jest
.spyOn(service, 'checkIndexEfficiency')
.mockResolvedValue([]);
const getConnectionStatusSpy = jest
.spyOn(service, 'getConnectionStatus')
.mockResolvedValue({});
const getPerformanceMetricsSpy = jest
.spyOn(service, 'getPerformanceMetrics')
.mockResolvedValue({});
await service.performanceCheck();
@@ -322,7 +340,9 @@ describe('PerformanceMonitorService', () => {
});
it('should handle errors during performance check', async () => {
jest.spyOn(service, 'checkSlowQueries').mockRejectedValue(new Error('Check failed'));
jest
.spyOn(service, 'checkSlowQueries')
.mockRejectedValue(new Error('Check failed'));
jest.spyOn(service, 'checkTableSizes').mockResolvedValue([]);
jest.spyOn(service, 'checkIndexEfficiency').mockResolvedValue([]);
jest.spyOn(service, 'getConnectionStatus').mockResolvedValue({});
@@ -332,4 +352,4 @@ describe('PerformanceMonitorService', () => {
await expect(service.performanceCheck()).resolves.not.toThrow();
});
});
});
});