import BaseService from "@Services/BaseService"; import { Service } from "typedi"; import { Notes, Prisma } from "@prisma/client"; import NotesRepository from "@Repositories/NotesRepository"; import Note from "le-coffre-resources/dist/Customer/Note"; @Service() export default class NotesService extends BaseService { constructor( private notesRepository: NotesRepository, ) { super(); } /** * @description : Get all notes * @throws {Error} If notes cannot be get */ public async get(query: Prisma.NotesFindManyArgs) { return this.notesRepository.findMany(query); } /** * @description : Get a note by uid * @throws {Error} If note cannot be get */ public async getByUid(uid: string, query?: Prisma.NotesInclude) { return this.notesRepository.findOneByUid(uid, query); } /** * @description : Create a new note * @throws {Error} If note cannot be created */ public async create(noteEntity: Note): Promise { return this.notesRepository.create(noteEntity); } /** * @description : Modify a note * @throws {Error} If note cannot be modified */ public async update(noteUid: string, noteEntity: Note): Promise { return this.notesRepository.update(noteUid, noteEntity); } }