docs(stocks): implement CRUD operations for product stocks
This update introduces several features within the stock service and controller, including creating new stock for a product, altering existing product stock, retrieving current stock, and managing product stocks with pagination.
This commit is contained in:
parent
3b201d63fe
commit
3451f17123
@ -2,5 +2,11 @@ import { Controller } from '@nestjs/common';
|
|||||||
|
|
||||||
@Controller('stocks')
|
@Controller('stocks')
|
||||||
export class StocksController {
|
export class StocksController {
|
||||||
//TODO CRUD by admin
|
//POST new stock of a product (via id) [admin]
|
||||||
|
|
||||||
|
//PATCH existing stock of a product (via id) [admin]
|
||||||
|
|
||||||
|
//GET current stock of a product [user]
|
||||||
|
|
||||||
|
//GET product with more or less stock (10 each)
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,38 @@ import { Injectable } from '@nestjs/common';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StocksService {
|
export class StocksService {
|
||||||
//CRUD on products stocks
|
//create a new stock for a product
|
||||||
|
async createStock(productId: string, quantity: number) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
|
|
||||||
|
//alter an existing stock of a product (via product id)
|
||||||
|
async alterStock(productId: string, newQuantity: number) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
|
|
||||||
|
//get the current stock of a product (via product id)
|
||||||
|
async getCurrentStock(productId: string) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
|
|
||||||
|
//get products with more or less stock (10 each)
|
||||||
|
async getProductsRankedByStock(quantity: number, asc: boolean) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
|
|
||||||
|
//get all product's stocks with pagination
|
||||||
|
async getAllStocks(page: number, limit: number) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
|
|
||||||
|
//decrement stock of a product (via product id and quantity to decrement)
|
||||||
|
async decrementStock(productId: string, quantityToDrop: number) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
|
|
||||||
|
//increment stock of a product (via product id and quantity to increment)
|
||||||
|
async incrementStock(productId: string, quantity: number) {
|
||||||
|
// implementation here
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user