feat(pos): update POS controller and service to handle posId for stock and product categories

This commit is contained in:
2025-12-26 16:47:34 +03:30
parent b4f226fb3a
commit d59be5995d
2 changed files with 87 additions and 21 deletions
+22 -12
View File
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Post } from '@nestjs/common'
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common'
import { CreateOrderDto } from './dto/create-pos.dto'
import { PosService } from './pos.service'
@@ -6,21 +6,31 @@ import { PosService } from './pos.service'
export class PosController {
constructor(private readonly posService: PosService) {}
@Get()
getInfo() {
return this.posService.getInfo()
@Get('/:posId')
getInfo(@Param('posId') posId: string) {
return this.posService.getInfo(Number(posId))
}
@Get('/stock')
async getStock() {
const inventoryId = await this.posService.getDefaultInventoryId()
return this.posService.getStock(inventoryId!)
@Get('/:posId/stock')
async getStock(
@Param('posId') posId: string,
@Query('isAvailable') isAvailable?: string,
@Query('page') page?: string,
@Query('pageSize') pageSize?: string,
@Query('q') q?: string,
) {
const options = {
isAvailable: isAvailable ? isAvailable === 'true' : undefined,
page: page ? Number(page) : undefined,
pageSize: pageSize ? Number(pageSize) : undefined,
q,
}
return this.posService.getStock(Number(posId), options)
}
@Get('/product-categories')
async getProductCategories() {
const inventoryId = await this.posService.getDefaultInventoryId()
return this.posService.getProductCategories(inventoryId!)
@Get('/:posId/product-categories')
async getProductCategories(@Param('posId') posId: string) {
return this.posService.getProductCategories(Number(posId))
}
@Post('/orders/create')