2023-07-04 18:09:45 +02:00

49 lines
1.4 KiB
TypeScript

import { Deeds, Prisma } from "@prisma/client";
import DeedsRepository from "@Repositories/DeedsRepository";
import BaseService from "@Services/BaseService";
import { Deed } from "le-coffre-resources/dist/Notary";
import { Service } from "typedi";
@Service()
export default class DeedsService extends BaseService {
constructor(private deedRepository: DeedsRepository) {
super();
}
/**
* @description : Get all deeds
* @throws {Error} If deeds cannot be get
*/
public async get(query: Prisma.DeedsFindManyArgs) {
return this.deedRepository.findMany(query);
}
/**
* @description : Create a new deed with document types
* @throws {Error} If deeds cannot be created
*/
public async create(deed: Deed): Promise<Deeds> {
return this.deedRepository.create(deed);
}
/**
* @description : Update data of a deed with document types
* @throws {Error} If deeds cannot be updated with document types or one of them
*/
public async update(uid: string, deed: Deed): Promise<Deeds> {
return this.deedRepository.update(uid, deed);
}
/**
* @description : Get a deed by uid
* @throws {Error} If deed-type cannot be get by uid
*/
public async getByUid(uid: string, query?: Prisma.DeedsInclude) {
return this.deedRepository.findOneByUid(uid, query);
}
public async getOneByUidWithOffice(uid: string) {
return this.deedRepository.findOneByUidWithOffice(uid);
}
}