feat: add generated code

This commit is contained in:
aid-orchestrator
2026-05-12 09:31:32 +00:00
parent 62b4b052a3
commit 12179f2160
51 changed files with 1143 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { Product, Prisma } from '@prisma/client';
@Injectable()
export class ProductService {
constructor(private prisma: PrismaService) {}
async findAll(params: {
skip?: number;
take?: number;
where?: Prisma.ProductWhereInput;
orderBy?: Prisma.ProductOrderByWithRelationInput;
}): Promise<{ data: Product[]; total: number }> {
const { skip, take, where, orderBy } = params;
const [data, total] = await this.prisma.$transaction([
this.prisma.product.findMany({
skip,
take,
where,
orderBy,
include: {
productType: true,
parent: true,
},
}),
this.prisma.product.count({ where }),
]);
return { data, total };
}
async findOne(where: Prisma.ProductWhereUniqueInput): Promise<Product | null> {
return this.prisma.product.findUnique({
where,
include: {
productType: true,
parent: true,
},
});
}
async create(data: Prisma.ProductCreateInput): Promise<Product> {
return this.prisma.product.create({
data,
include: {
productType: true,
parent: true,
},
});
}
async update(params: {
where: Prisma.ProductWhereUniqueInput;
data: Prisma.ProductUpdateInput;
}): Promise<Product> {
return this.prisma.product.update({
...params,
include: {
productType: true,
parent: true,
},
});
}
async remove(where: Prisma.ProductWhereUniqueInput): Promise<Product> {
return this.prisma.product.delete({
where,
include: {
productType: true,
parent: true,
},
});
}
}