feat: multi-module iteration
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { HqAuthGuard } from '../../common/guards/hq-auth.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 { TradeService } from '../trade/trade.service';
|
||||
import {
|
||||
AdminCreateInvoiceDto,
|
||||
IssueInvoiceDto,
|
||||
RejectInvoiceDto,
|
||||
} from '../trade/dto/after-sale.dto';
|
||||
|
||||
@Controller('admin/invoices')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminInvoicesController {
|
||||
constructor(private readonly tradeService: TradeService) {}
|
||||
|
||||
@Get()
|
||||
list(
|
||||
@Query('status') status?: string,
|
||||
@Query('page') page = '1',
|
||||
@Query('pageSize') pageSize = '20',
|
||||
) {
|
||||
return this.tradeService.adminListInvoices({
|
||||
status,
|
||||
page: Number(page),
|
||||
pageSize: Number(pageSize),
|
||||
});
|
||||
}
|
||||
|
||||
@Post()
|
||||
@HqOperation({
|
||||
action: HqOperationAction.INVOICE_CREATE,
|
||||
refType: 'INVOICE',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
create(@Body() body: AdminCreateInvoiceDto) {
|
||||
return this.tradeService.adminCreateInvoice(body);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.tradeService.adminGetInvoice(BigInt(id));
|
||||
}
|
||||
|
||||
@Post(':id/issue')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.INVOICE_ISSUE,
|
||||
refType: 'INVOICE',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
issue(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() body: IssueInvoiceDto,
|
||||
) {
|
||||
return this.tradeService.adminIssueInvoice(BigInt(id), user.actorId, body);
|
||||
}
|
||||
|
||||
@Post(':id/reject')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.INVOICE_REJECT,
|
||||
refType: 'INVOICE',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
reject(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() body: RejectInvoiceDto,
|
||||
) {
|
||||
return this.tradeService.adminRejectInvoice(BigInt(id), user.actorId, body.remark);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user