46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
// import ProjectsRepository from "@Common/repositories/projects/ProjectsRepository";
|
|
import { Offices } from "@prisma/client";
|
|
import OfficesRepository from "@Repositories/OfficesRepository";
|
|
import BaseService from "@Services/BaseService";
|
|
import { Office as OfficeRessource } from "le-coffre-resources/dist/SuperAdmin";
|
|
import { Service } from "typedi";
|
|
|
|
@Service()
|
|
export default class OfficesService extends BaseService {
|
|
constructor(private officeRepository: OfficesRepository) {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* @description : Get all offices
|
|
* @throws {Error} If offices cannot be get
|
|
*/
|
|
public async get(query: any): Promise<Offices[]> {
|
|
return this.officeRepository.findMany(query);
|
|
}
|
|
|
|
/**
|
|
* @description : Create a new office
|
|
* @throws {Error} If office cannot be created
|
|
*/
|
|
public async create(officeEntity: OfficeRessource): Promise<Offices> {
|
|
return this.officeRepository.create(officeEntity);
|
|
}
|
|
|
|
/**
|
|
* @description : Modify an office
|
|
* @throws {Error} If office cannot be modified
|
|
*/
|
|
public async update(uid: string, officeEntity: OfficeRessource): Promise<Offices> {
|
|
return this.officeRepository.update(uid, officeEntity);
|
|
}
|
|
|
|
/**
|
|
* @description : Get a office by uid
|
|
* @throws {Error} If office cannot be get
|
|
*/
|
|
public async getByUid(uid: string): Promise<Offices> {
|
|
return this.officeRepository.findOneByUid(uid);
|
|
}
|
|
}
|