4c38a9dd2b
增加hq管理端日志
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
|
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
|
import { SuperAdminGuard } from '../../common/guards/super-admin.guard';
|
|
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
|
|
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
|
|
import { AdminUsersService } from './admin-users.service';
|
|
import { AdminUsersQueryDto } from './dto/admin-query.dto';
|
|
import { BatchDeleteUsersConfirmDto, BatchDeleteUsersDto } from './dto/admin-mutate.dto';
|
|
|
|
@Controller('admin/users')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminUsersController {
|
|
constructor(private readonly usersService: AdminUsersService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: AdminUsersQueryDto) {
|
|
return this.usersService.list(query);
|
|
}
|
|
|
|
@Post('batch-delete/preview')
|
|
@UseGuards(SuperAdminGuard)
|
|
previewBatchDelete(@Body() dto: BatchDeleteUsersDto) {
|
|
return this.usersService.previewBatchDelete(dto.ids.map((id) => BigInt(id)));
|
|
}
|
|
|
|
@Post('batch-delete')
|
|
@UseGuards(SuperAdminGuard)
|
|
@HqOperation({
|
|
action: HqOperationAction.USER_BATCH_DELETE,
|
|
refType: 'USER',
|
|
batch: true,
|
|
includeBody: true,
|
|
})
|
|
batchDelete(@Body() dto: BatchDeleteUsersConfirmDto) {
|
|
return this.usersService.batchDeleteUsers(
|
|
dto.ids.map((id) => BigInt(id)),
|
|
dto.confirmRisk,
|
|
);
|
|
}
|
|
|
|
@Get(':id')
|
|
detail(@Param('id') id: string) {
|
|
return this.usersService.detail(BigInt(id));
|
|
}
|
|
|
|
@Delete(':id')
|
|
@UseGuards(SuperAdminGuard)
|
|
@HqOperation({
|
|
action: HqOperationAction.USER_DELETE,
|
|
refType: 'USER',
|
|
refIdParam: 'id',
|
|
})
|
|
remove(@Param('id') id: string) {
|
|
return this.usersService.deleteUser(BigInt(id));
|
|
}
|
|
}
|