4c38a9dd2b
增加hq管理端日志
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Put, 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 { AdminHqAccountsService } from './admin-hq-accounts.service';
|
|
import { AdminHqAccountsQueryDto } from './dto/admin-query.dto';
|
|
import { CreateHqAccountDto, UpdateHqAccountDto } from './dto/admin-mutate.dto';
|
|
|
|
@Controller('admin/hq-accounts')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminHqAccountsController {
|
|
constructor(private readonly service: AdminHqAccountsService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: AdminHqAccountsQueryDto) {
|
|
return this.service.list(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
detail(@Param('id') id: string) {
|
|
return this.service.detail(BigInt(id));
|
|
}
|
|
|
|
@Post()
|
|
@UseGuards(SuperAdminGuard)
|
|
@HqOperation({
|
|
action: HqOperationAction.HQ_ACCOUNT_CREATE,
|
|
refType: 'HQ_ACCOUNT',
|
|
refIdField: 'id',
|
|
includeBody: true,
|
|
})
|
|
create(@Body() dto: CreateHqAccountDto) {
|
|
return this.service.create(dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
@UseGuards(SuperAdminGuard)
|
|
@HqOperation({
|
|
action: HqOperationAction.HQ_ACCOUNT_UPDATE,
|
|
refType: 'HQ_ACCOUNT',
|
|
refIdParam: 'id',
|
|
includeBody: true,
|
|
})
|
|
update(@Param('id') id: string, @Body() dto: UpdateHqAccountDto) {
|
|
return this.service.update(BigInt(id), dto);
|
|
}
|
|
}
|