Initial commit: Mana Collection NestJS backend.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { UserRole } from '@prisma/client';
|
||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||
import { Roles } from '../auth/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from '../auth/guards/roles.guard';
|
||||
import type { AuthUser } from '../auth/auth.types';
|
||||
import {
|
||||
UpdateOrderStatusDto,
|
||||
UpdateOrderStoreStatusDto,
|
||||
} from './dto/order.dto';
|
||||
import { OrdersService } from './orders.service';
|
||||
|
||||
@Controller('orders')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(UserRole.STORE_ADMIN, UserRole.SUPER_ADMIN)
|
||||
export class OrdersController {
|
||||
constructor(private readonly orders: OrdersService) {}
|
||||
|
||||
@Get()
|
||||
list(@CurrentUser() user: AuthUser) {
|
||||
return this.orders.list(user);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
||||
return this.orders.findOne(user, id);
|
||||
}
|
||||
|
||||
@Patch(':id/fulfillment')
|
||||
@Roles(UserRole.STORE_ADMIN)
|
||||
updateFulfillment(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateOrderStoreStatusDto,
|
||||
) {
|
||||
return this.orders.updateStoreFulfillment(user, id, dto);
|
||||
}
|
||||
|
||||
@Patch(':id/status')
|
||||
@Roles(UserRole.SUPER_ADMIN)
|
||||
updateStatus(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateOrderStatusDto,
|
||||
) {
|
||||
return this.orders.updateStatus(user, id, dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user