@@ -0,0 +1,55 @@
|
||||
import { BadRequestException, Body, Controller, Get, Param, Post, Put, UseGuards } from '@nestjs/common';
|
||||
import type { UpdateWecomReportPushRequest } from '@dukang/shared-types';
|
||||
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
||||
import {
|
||||
HqPermissionGuard,
|
||||
RequireHqPermissions,
|
||||
} from '../../common/guards/hq-permission.guard';
|
||||
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
|
||||
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
|
||||
import { AdminWecomReportsService } from './admin-wecom-reports.service';
|
||||
|
||||
@Controller('admin/wecom-reports')
|
||||
@UseGuards(HqAuthGuard, HqPermissionGuard)
|
||||
@RequireHqPermissions('wecom_bots')
|
||||
export class AdminWecomReportsController {
|
||||
constructor(private readonly service: AdminWecomReportsService) {}
|
||||
|
||||
@Get()
|
||||
list() {
|
||||
return this.service.list();
|
||||
}
|
||||
|
||||
@Get(':kind')
|
||||
detail(@Param('kind') kind: string) {
|
||||
return this.service.detail(this.service.parseKind(kind));
|
||||
}
|
||||
|
||||
@Put(':kind')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.WECOM_REPORT_UPDATE,
|
||||
refType: 'WECOM_REPORT',
|
||||
refIdField: 'kind',
|
||||
includeBody: true,
|
||||
})
|
||||
update(@Param('kind') kind: string, @Body() body: UpdateWecomReportPushRequest) {
|
||||
return this.service.update(this.service.parseKind(kind), body);
|
||||
}
|
||||
|
||||
@Post(':kind/preview')
|
||||
preview(@Param('kind') kind: string) {
|
||||
return this.service.preview(this.service.parseKind(kind));
|
||||
}
|
||||
|
||||
@Post(':kind/send')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.WECOM_REPORT_SEND,
|
||||
refType: 'WECOM_REPORT',
|
||||
refIdField: 'kind',
|
||||
})
|
||||
async send(@Param('kind') kind: string) {
|
||||
const result = await this.service.send(this.service.parseKind(kind));
|
||||
if (!result.ok) throw new BadRequestException(result.message);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user