test: harden business boundary conditions

This commit is contained in:
2026-07-15 00:03:55 +08:00
parent 17a5046ea0
commit b1f35f9d1a
65 changed files with 2311 additions and 293 deletions

View File

@@ -3,6 +3,7 @@ import { OperationLogsService } from './operation-logs.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { RequirePermission } from '../auth/decorators/permission.decorator';
import { extractRequestInfo } from '../common/request-utils';
import { CreateAuditLogDto, QueryOperationLogsDto } from './dto/operation-log.dto';
@UseGuards(JwtAuthGuard)
@Controller('operation-logs')
@@ -11,29 +12,15 @@ export class OperationLogsController {
@Get()
@RequirePermission('log:view')
findAll(
@Query('module') module?: string,
@Query('userId') userId?: string,
@Query('startDate') startDate?: string,
@Query('endDate') endDate?: string,
@Query('page') page?: string,
@Query('pageSize') pageSize?: string,
) {
return this.service.findAll({
module,
userId: userId ? +userId : undefined,
startDate,
endDate,
page: page ? +page : 1,
pageSize: pageSize ? +pageSize : 50,
});
findAll(@Query() query: QueryOperationLogsDto) {
return this.service.findAll(query);
}
@Post('audit')
@RequirePermission('log:create')
async createAuditLog(
@Body() body: { module: string; action: string; targetId?: number; targetType?: string; detail?: string },
@Body() body: CreateAuditLogDto,
@Request() req: any,
) {
const { ipAddress, userAgent } = extractRequestInfo(req);