2023-05-15 10:09:51 +02:00

45 lines
1.2 KiB
TypeScript

import { Deeds } from "@prisma/client";
import DeedsRepository from "@Repositories/DeedsRepository";
import BaseService from "@Services/BaseService";
import { Deed } from "le-coffre-resources/dist/SuperAdmin";
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: any) {
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(deeduid: string, deed: Deed): Promise<Deeds> {
return this.deedRepository.update(deeduid, deed);
}
/**
* @description : Get a deed by uid
* @throws {Error} If deed-type cannot be get by uid
*/
public async getByUid(uid: string, query?: any): Promise<Deeds | null> {
return this.deedRepository.findOneByUid(uid, query);
}
}