/
opt
/
mawid
/
apps
/
api
/
src
/
services
/
/opt/mawid/apps/api/src/services
mkdir
upload
Name
Size
Mode
Actions
services.controller.ts
1343
0644
edit
dl
rm
services.module.ts
299
0644
edit
dl
rm
services.service.ts
1164
0644
edit
dl
rm
Edit:
/opt/mawid/apps/api/src/services/services.service.ts
(1164B)
import { Injectable, NotFoundException } from '@nestjs/common'; import type { CreateServiceInput, UpdateServiceInput } from '@mawid/shared'; import { PrismaService } from '../prisma/prisma.service'; @Injectable() export class ServicesService { constructor(private readonly prisma: PrismaService) {} list(clinicId: string) { return this.prisma.service.findMany({ where: { clinicId }, orderBy: { createdAt: 'asc' }, }); } async get(clinicId: string, id: string) { const service = await this.prisma.service.findFirst({ where: { id, clinicId } }); if (!service) throw new NotFoundException('Service not found'); return service; } create(clinicId: string, input: CreateServiceInput) { return this.prisma.service.create({ data: { clinicId, ...input } }); } async update(clinicId: string, id: string, input: UpdateServiceInput) { await this.get(clinicId, id); return this.prisma.service.update({ where: { id }, data: input }); } async remove(clinicId: string, id: string) { await this.get(clinicId, id); await this.prisma.service.delete({ where: { id } }); return { deleted: true }; } }
Save
cmd:
run