From da8571f267bbcdfa339ab58a7754a4480c7c74a3 Mon Sep 17 00:00:00 2001 From: toir-bot Date: Mon, 13 Apr 2026 11:45:43 +0000 Subject: [PATCH] feat: add generated code: backend/src/equipment/equipment.service.ts --- backend/src/equipment/equipment.service.ts | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 backend/src/equipment/equipment.service.ts diff --git a/backend/src/equipment/equipment.service.ts b/backend/src/equipment/equipment.service.ts new file mode 100644 index 0000000..1ca502d --- /dev/null +++ b/backend/src/equipment/equipment.service.ts @@ -0,0 +1,41 @@ +import { Injectable } from '@nestjs/common'; +import { PrismaService } from '../prisma/prisma.service'; +import { Equipment, Prisma } from 'generated/prisma'; + +@Injectable() +export class EquipmentService { + constructor(private prisma: PrismaService) {} + + async findAll(params: { + skip?: number; + take?: number; + where?: Prisma.EquipmentWhereInput; + orderBy?: Prisma.EquipmentOrderByWithRelationInput; + }): Promise<[Equipment[], number]> { + const { skip, take, where, orderBy } = params; + const [data, total] = await Promise.all([ + this.prisma.equipment.findMany({ skip, take, where, orderBy }), + this.prisma.equipment.count({ where }), + ]); + return [data, total]; + } + + async findOne(where: Prisma.EquipmentWhereUniqueInput): Promise { + return this.prisma.equipment.findUnique({ where }); + } + + async create(data: Prisma.EquipmentCreateInput): Promise { + return this.prisma.equipment.create({ data }); + } + + async update(params: { + where: Prisma.EquipmentWhereUniqueInput; + data: Prisma.EquipmentUpdateInput; + }): Promise { + return this.prisma.equipment.update(params); + } + + async remove(where: Prisma.EquipmentWhereUniqueInput): Promise { + return this.prisma.equipment.delete({ where }); + } +} \ No newline at end of file