feat: add product variant management functionality

- Implemented CreateProductVariantDto and UpdateProductVariantDto for product variant data transfer.
- Developed ProductVariantsController to handle CRUD operations for product variants.
- Created ProductVariantsService to interact with the database using Prisma.
- Added ProductVariantsModule to encapsulate the product variant feature.
- Included response mapping for consistent API responses.
This commit is contained in:
2025-12-06 17:48:10 +03:30
parent 7cb9d7d037
commit a782d61890
68 changed files with 4155 additions and 3334 deletions
+17 -11
View File
@@ -1,27 +1,33 @@
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from '../common/response/response-mapper'
import { PrismaService } from '../prisma/prisma.service'
@Injectable()
export class CustomersService {
constructor(private prisma: PrismaService) {}
create(data: any) {
return this.prisma.customer.create({ data })
async create(data: any) {
const item = await this.prisma.customer.create({ data })
return ResponseMapper.create(item)
}
findAll() {
return this.prisma.customer.findMany()
async findAll() {
const items = await this.prisma.customer.findMany()
return ResponseMapper.list(items)
}
findOne(id: number) {
return this.prisma.customer.findUnique({ where: { id } })
async findOne(id: number) {
const item = await this.prisma.customer.findUnique({ where: { id } })
if (!item) return null
return ResponseMapper.single(item)
}
update(id: number, data: any) {
return this.prisma.customer.update({ where: { id }, data })
async update(id: number, data: any) {
const item = await this.prisma.customer.update({ where: { id }, data })
return ResponseMapper.update(item)
}
remove(id: number) {
return this.prisma.customer.delete({ where: { id } })
async remove(id: number) {
const item = await this.prisma.customer.delete({ where: { id } })
return ResponseMapper.single(item)
}
}