feat: 技术支持工单/企微权限/开发版本管理/消息推送等迭代
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
NotFoundException,
|
||||
Param,
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
||||
import { SuperAdminGuard } from '../../common/guards/super-admin.guard';
|
||||
import { AuthUser } from '../../common/guards/jwt-auth.guard';
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
||||
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
|
||||
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
|
||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
import { SupportTicketService } from '../common/support-ticket.service';
|
||||
import {
|
||||
CreateSupportTicketDto,
|
||||
RejectSupportTicketDto,
|
||||
SupportTicketListQueryDto,
|
||||
SupportTicketRemarkDto,
|
||||
} from '../common/dto/support-ticket.dto';
|
||||
|
||||
@Controller('admin/support-tickets')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminSupportTicketsController {
|
||||
constructor(
|
||||
private readonly service: SupportTicketService,
|
||||
private readonly prisma: PrismaService,
|
||||
) {}
|
||||
|
||||
private async resolveHqAccount(user: AuthUser) {
|
||||
const account = await this.prisma.hqAccount.findUnique({
|
||||
where: { id: user.actorId },
|
||||
select: { id: true, name: true },
|
||||
});
|
||||
if (!account) throw new NotFoundException('HQ 账户不存在');
|
||||
return account;
|
||||
}
|
||||
|
||||
@Get()
|
||||
list(@Query() query: SupportTicketListQueryDto) {
|
||||
return this.service.list(query);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@HqOperation({
|
||||
action: HqOperationAction.SUPPORT_TICKET_CREATE,
|
||||
refType: 'SUPPORT_TICKET',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
async create(@CurrentUser() user: AuthUser, @Body() body: CreateSupportTicketDto) {
|
||||
const account = await this.resolveHqAccount(user);
|
||||
return this.service.create(body, account);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.service.detail(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/approve')
|
||||
@UseGuards(SuperAdminGuard)
|
||||
@HqOperation({
|
||||
action: HqOperationAction.SUPPORT_TICKET_APPROVE,
|
||||
refType: 'SUPPORT_TICKET',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
async approve(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() body: SupportTicketRemarkDto,
|
||||
) {
|
||||
const account = await this.resolveHqAccount(user);
|
||||
return this.service.approve(BigInt(id), account, body);
|
||||
}
|
||||
|
||||
@Post(':id/reject')
|
||||
@UseGuards(SuperAdminGuard)
|
||||
@HqOperation({
|
||||
action: HqOperationAction.SUPPORT_TICKET_REJECT,
|
||||
refType: 'SUPPORT_TICKET',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
async reject(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() body: RejectSupportTicketDto,
|
||||
) {
|
||||
const account = await this.resolveHqAccount(user);
|
||||
return this.service.reject(BigInt(id), account, body);
|
||||
}
|
||||
|
||||
@Post(':id/start-testing')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.SUPPORT_TICKET_START_TESTING,
|
||||
refType: 'SUPPORT_TICKET',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
startTesting(@Param('id') id: string, @Body() body: SupportTicketRemarkDto) {
|
||||
return this.service.startTesting(BigInt(id), body);
|
||||
}
|
||||
|
||||
@Post(':id/pass')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.SUPPORT_TICKET_PASS,
|
||||
refType: 'SUPPORT_TICKET',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
pass(@Param('id') id: string, @Body() body: SupportTicketRemarkDto) {
|
||||
return this.service.pass(BigInt(id), body);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user