feat: add teacher list and profile API

This commit is contained in:
2026-07-06 15:33:12 +08:00
parent 1c097dc230
commit 9e0d9ff39c
2 changed files with 107 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import {
Delete,
Body,
Param,
Query,
UseGuards,
Request,
BadRequestException,
@@ -259,4 +260,43 @@ export class RbacController {
async getTeacherWorkspace(@Request() req: any) {
return this.rbacService.getTeacherWorkspace(req.user?.id);
}
// ---- 教师管理 ----
@Get('teachers')
@RequirePermission('user:view')
async getTeachers(
@Query('search') search?: string,
@Query('page') page?: string,
@Query('pageSize') pageSize?: string,
) {
return this.rbacService.getTeachers({
search,
page: page ? +page : undefined,
pageSize: pageSize ? +pageSize : undefined,
});
}
@Put('teachers/:id/profile')
@RequirePermission('user:edit')
async updateTeacherProfile(
@Param('id') id: string,
@Body() profile: UpdateProfileDto,
@Request() req: { user?: { id: number; username: string } },
) {
const { ipAddress, userAgent } = extractRequestInfo(req);
const result = await this.rbacService.updateTeacherProfile(+id, profile);
await this.logService.log({
userId: req.user?.id,
username: req.user?.username,
module: '教师管理',
action: '编辑档案',
targetId: +id,
targetType: 'user',
detail: '更新教师档案',
ipAddress,
userAgent,
});
return result;
}
}