feat: add mark-staff/mark-student endpoints with studentStatus in user list

This commit is contained in:
2026-07-09 10:06:31 +08:00
parent 6e0ad8759f
commit 14eec2852a
2 changed files with 89 additions and 3 deletions

View File

@@ -127,8 +127,9 @@ export class RbacController {
@Get('users')
@RequirePermission('user:view')
getUsers() {
return this.rbacService.findAllUsers();
getUsers(@Query('isArchived') isArchived?: string) {
const archived = isArchived === 'true';
return this.rbacService.findAllUsers(archived);
}
@Post('users')
@@ -219,6 +220,50 @@ export class RbacController {
}
}
@Put('users/:id/archive')
@RequirePermission('user:edit')
async archiveUser(@Param('id') id: string) {
try {
return await this.rbacService.archiveUser(+id);
} catch (e: unknown) {
const err = e as { message?: string };
throw new BadRequestException(err?.message);
}
}
@Put('users/:id/restore')
@RequirePermission('user:edit')
async restoreUser(@Param('id') id: string) {
try {
return await this.rbacService.restoreUser(+id);
} catch (e: unknown) {
const err = e as { message?: string };
throw new BadRequestException(err?.message);
}
}
@Put('users/:id/mark-staff')
@RequirePermission('user:edit')
async markAsStaff(@Param('id') id: string) {
try {
return await this.rbacService.markAsStaff(+id);
} catch (e: unknown) {
const err = e as { message?: string };
throw new BadRequestException(err?.message);
}
}
@Put('users/:id/mark-student')
@RequirePermission('user:edit')
async markAsStudent(@Param('id') id: string) {
try {
return await this.rbacService.markAsStudent(+id);
} catch (e: unknown) {
const err = e as { message?: string };
throw new BadRequestException(err?.message);
}
}
// ---- 用户资料 ----
@Get('users/:id/profile')