feat: implement inventory, product brand, product category, product info, product, role, store, user, and vendor modules with CRUD operations
- Added Create and Update DTOs for Inventory, Product Brand, Product Category, Product Info, Product, Role, Store, User, and Vendor. - Implemented InventoriesController, ProductBrandsController, ProductCategoriesController, ProductInfoController, ProductsController, RolesController, StoresController, UsersController, and VendorsController with respective CRUD endpoints. - Developed InventoriesService, ProductBrandsService, ProductCategoriesService, ProductInfoService, ProductsService, RolesService, StoresService, UsersService, and VendorsService to handle business logic. - Created PrismaModule and PrismaService for database interactions using Prisma with MariaDB adapter. - Configured application with Swagger for API documentation and added global interceptors for logging and response mapping. - Established e2e testing setup with Jest for the application.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
export class CreateProductDto {
|
||||
name: string
|
||||
description?: string
|
||||
sku?: string
|
||||
barcode?: string
|
||||
imageUrl?: string
|
||||
attachmentId?: number
|
||||
unit: string
|
||||
discount?: number
|
||||
quantity?: number
|
||||
alertQuantity?: number
|
||||
isActive?: boolean
|
||||
isFeatured?: boolean
|
||||
productInfoId: number
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export class UpdateProductDto {
|
||||
name?: string
|
||||
description?: string
|
||||
sku?: string
|
||||
barcode?: string
|
||||
imageUrl?: string
|
||||
attachmentId?: number
|
||||
unit?: string
|
||||
discount?: number
|
||||
quantity?: number
|
||||
alertQuantity?: number
|
||||
isActive?: boolean
|
||||
isFeatured?: boolean
|
||||
productInfoId?: number
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { CreateProductDto } from './dto/create-product.dto'
|
||||
import { UpdateProductDto } from './dto/update-product.dto'
|
||||
import { ProductsService } from './products.service'
|
||||
|
||||
@Controller('products')
|
||||
export class ProductsController {
|
||||
constructor(private readonly productsService: ProductsService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() dto: CreateProductDto) {
|
||||
return this.productsService.create(dto)
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.productsService.findAll()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.productsService.findOne(Number(id))
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() dto: UpdateProductDto) {
|
||||
return this.productsService.update(Number(id), dto)
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.productsService.remove(Number(id))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { PrismaModule } from '../prisma/prisma.module'
|
||||
import { ProductsController } from './products.controller'
|
||||
import { ProductsService } from './products.service'
|
||||
|
||||
@Module({
|
||||
imports: [PrismaModule],
|
||||
controllers: [ProductsController],
|
||||
providers: [ProductsService],
|
||||
})
|
||||
export class ProductsModule {}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { PrismaService } from '../prisma/prisma.service'
|
||||
|
||||
@Injectable()
|
||||
export class ProductsService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
create(data: any) {
|
||||
return this.prisma.product.create({ data })
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.prisma.product.findMany()
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return this.prisma.product.findUnique({ where: { id } })
|
||||
}
|
||||
|
||||
update(id: number, data: any) {
|
||||
return this.prisma.product.update({ where: { id }, data })
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return this.prisma.product.delete({ where: { id } })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user