feat: integrate CampusScope.filter() into all business services (12 services + 12 modules)
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Body, Query, UseGuards, Request } from '@nestjs/common';
|
||||
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';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@RequirePermission('log:view')
|
||||
@Controller('operation-logs')
|
||||
export class OperationLogsController {
|
||||
constructor(private service: OperationLogsService) {}
|
||||
|
||||
@Get()
|
||||
@RequirePermission('log:view')
|
||||
findAll(
|
||||
@Query('module') module?: string,
|
||||
@Query('userId') userId?: string,
|
||||
@@ -27,4 +28,23 @@ export class OperationLogsController {
|
||||
pageSize: pageSize ? +pageSize : 50,
|
||||
});
|
||||
}
|
||||
|
||||
@Post('audit')
|
||||
async createAuditLog(
|
||||
@Body() body: { module: string; action: string; targetId?: number; targetType?: string; detail?: string },
|
||||
@Request() req: any,
|
||||
) {
|
||||
const { ipAddress, userAgent } = extractRequestInfo(req);
|
||||
return this.service.log({
|
||||
userId: req.user?.id,
|
||||
username: req.user?.username,
|
||||
module: body.module,
|
||||
action: body.action,
|
||||
targetId: body.targetId,
|
||||
targetType: body.targetType,
|
||||
detail: body.detail,
|
||||
ipAddress,
|
||||
userAgent,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user