46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Post,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import {
|
|
CurrentPrincipal,
|
|
RequirePermission,
|
|
} from '../identity/access.decorator';
|
|
import type { Principal } from '../identity/identity.types';
|
|
import { SchemaPipe } from '../common/validation.pipe';
|
|
import { pageSchema, type PageInput } from '../identity/identity.schemas';
|
|
import { OrderStore } from './order.store';
|
|
|
|
@Controller('admin/orders')
|
|
export class OrderAdminController {
|
|
constructor(private readonly orders: OrderStore) {}
|
|
@Get()
|
|
@RequirePermission('orders.read')
|
|
list(
|
|
@CurrentPrincipal() actor: Principal,
|
|
@Query(new SchemaPipe(pageSchema)) page: PageInput,
|
|
) {
|
|
return this.orders.list(actor, page, true);
|
|
}
|
|
@Get(':id')
|
|
@RequirePermission('orders.read')
|
|
get(
|
|
@CurrentPrincipal() actor: Principal,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
) {
|
|
return this.orders.get(actor, id, true);
|
|
}
|
|
@Post(':id/cancel')
|
|
@RequirePermission('orders.manage')
|
|
cancel(
|
|
@CurrentPrincipal() actor: Principal,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
) {
|
|
return this.orders.cancel(actor, id, true);
|
|
}
|
|
}
|