Spaces:
Sleeping
Sleeping
import { | |
Controller, | |
Get, | |
Post, | |
Body, | |
Patch, | |
Param, | |
Delete, | |
Req, | |
} from '@nestjs/common'; | |
import { OrderService } from './order.service.js'; | |
import { CreateOrderDto } from './dto/create-order.dto.js'; | |
import { Role } from '../../common/enums/role.enum.js'; | |
'branchs/:branchId/orders') | (|
export class OrderController { | |
constructor(private readonly orderService: OrderService) {} | |
() | |
async create( | |
'branchId') branchId: string, ( | |
() req: Request, | |
() createOrderDto: CreateOrderDto, | |
) { | |
const userId = req['user'].sub; | |
const role = req['user'].roles; | |
console.log(req['user']); | |
if (role == Role.CUSTOMER) | |
return this.orderService.createFromCustomer( | |
branchId, | |
userId, | |
createOrderDto, | |
); | |
else | |
return this.orderService.createFromStaff( | |
branchId, | |
userId, | |
createOrderDto, | |
); | |
} | |
() | |
async findAll() { () req: Request | |
const userId = req['user'].sub; | |
console.log(req['user']); | |
return this.orderService.findAll(); | |
} | |
':id') | (|
async findOne('id') id: string) { ( | |
return this.orderService.findOne(+id); | |
} | |
// @Patch(':id') | |
// async update( | |
// @Param('id') id: string, | |
// @Body() updateOrderDto: UpdateOrderDto, | |
// ) { | |
// return this.orderService.update(+id, updateOrderDto); | |
// } | |
':id') | (|
remove('id') id: string) { ( | |
return this.orderService.remove(+id); | |
} | |
} | |