import { Injectable, NotFoundException } from '@nestjs/common'; import { Users } from '@prisma/client'; import { PrismaService } from 'src/prisma/prisma.service'; @Injectable() export abstract class AbstractUserService { constructor(protected readonly prisma: PrismaService) {} findAll(): Promise { return this.prisma.users.findMany(); } async findOne(user_id: number): Promise { const user = await this.prisma.users.findUnique({ where: { user_id } }); if (!user) { throw new NotFoundException(`User #${user_id} not found`); } return user; } async remove(user_id: number): Promise { await this.findOne(user_id); return this.prisma.users.delete({ where: { user_id } }); } }