hotfix delete document
This commit is contained in:
parent
9a26118839
commit
385d886fb4
@ -47,6 +47,12 @@ export default class DocumentsService extends BaseService {
|
||||
* @throws {Error} If document cannot be deleted
|
||||
*/
|
||||
public async delete(uid: string): Promise<Documents> {
|
||||
const documentEntity = await this.documentsRepository.findOneByUid(uid, { office_folder_has_customers: true });
|
||||
const document = Document.hydrate<Document>(documentEntity, { strategy: "excludeAll" });
|
||||
|
||||
if (document.files && document.files.length !== 0) {
|
||||
throw new Error("Can't delete a document with file");
|
||||
}
|
||||
return this.documentsRepository.delete(uid);
|
||||
}
|
||||
|
||||
@ -55,12 +61,6 @@ export default class DocumentsService extends BaseService {
|
||||
* @throws {Error} If document cannot be get by uid
|
||||
*/
|
||||
public async getByUid(uid: string, query?: any) {
|
||||
const documentEntity = await this.documentsRepository.findOneByUid(uid, { office_folder_has_customers: true });
|
||||
const document = Document.hydrate<Document>(documentEntity, { strategy: "excludeAll" });
|
||||
|
||||
if (document.files && document.files.length !== 0) {
|
||||
throw new Error("Can't delete a document with file");
|
||||
}
|
||||
return this.documentsRepository.findOneByUid(uid, query);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user