fix: normalize operation log module names across controllers

This commit is contained in:
2026-07-05 19:38:18 +08:00
parent efe13fe664
commit f962633f67
5 changed files with 63 additions and 53 deletions

View File

@@ -6,8 +6,8 @@ import {
Delete,
Body,
Param,
Query,
UseGuards,
Query,
Request,
Res,
UseInterceptors,
@@ -43,7 +43,7 @@ export class StudentsController {
@Get('export')
@RequirePermission('student:export')
async exportExcel(@Query('includeArchived') includeArchived?: string, @Res() res?: Response) {
async exportExcel(@Query('includeArchived') includeArchived?: string, @Res() res?: Response, @Request() req?: any) {
const students = await this.service.findAll({ includeArchived: includeArchived === 'true' });
const workbook = new ExcelJS.Workbook();
const ws = workbook.addWorksheet('学生名单');
@@ -81,6 +81,16 @@ export class StudentsController {
status: statusMap[s.status] || s.status,
});
}
const { ipAddress, userAgent } = extractRequestInfo(req);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生管理',
action: '导出学生',
detail: `导出 ${students.length} 名学生`,
ipAddress,
userAgent,
});
res!.setHeader(
'Content-Type',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
@@ -142,8 +152,8 @@ export class StudentsController {
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生',
action: '添加学生',
module: '学生管理',
action: '新增学生',
targetId: result.id,
targetType: 'student',
detail: `姓名: ${dto.name}, 电话: ${dto.phone || '无'}, 学号: ${dto.idNumber || '无'}`,
@@ -161,7 +171,7 @@ export class StudentsController {
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生',
module: '学生管理',
action: '编辑学生',
targetId: +id,
targetType: 'student',
@@ -180,8 +190,8 @@ export class StudentsController {
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生',
action: '归档学生',
module: '学生管理',
action: '删除学生',
targetId: +id,
targetType: 'student',
ipAddress,
@@ -198,8 +208,8 @@ export class StudentsController {
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生',
action: '批量归档学生',
module: '学生管理',
action: '批量删除学生',
detail: `IDs: ${(body.ids || []).join(',')}`,
ipAddress,
userAgent,
@@ -215,7 +225,7 @@ export class StudentsController {
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生',
module: '学生管理',
action: '恢复学生',
targetId: +id,
targetType: 'student',
@@ -262,8 +272,8 @@ export class StudentsController {
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '学生',
action: '批量导入',
module: '学生管理',
action: '导入学生',
detail: result.message,
ipAddress,
userAgent,