Fixed Document type name unique constraints

This commit is contained in:
Vins 2023-08-02 11:04:33 +02:00
parent a05be05b72
commit 609a099d0b
2 changed files with 5 additions and 1 deletions

View File

@ -58,6 +58,11 @@ export default class DocumentTypesController extends ApiController {
try { try {
//init DocumentType resource with request body values //init DocumentType resource with request body values
const documentTypeEntity = DocumentType.hydrate<DocumentType>(req.body); const documentTypeEntity = DocumentType.hydrate<DocumentType>(req.body);
const doesExist = await this.documentTypesService.get({ where: { name: documentTypeEntity.name } });
if (doesExist.length > 0) {
this.httpBadRequest(response, "Document type name already used");
return;
}
//validate user //validate user
await validateOrReject(documentTypeEntity, { groups: ["createDocumentType"], forbidUnknownValues: false }); await validateOrReject(documentTypeEntity, { groups: ["createDocumentType"], forbidUnknownValues: false });
//call service to get prisma entity //call service to get prisma entity

View File

@ -175,7 +175,6 @@ export default class OfficeFoldersController extends ApiController {
this.httpInternalError(response, error); this.httpInternalError(response, error);
return; return;
} }
this.httpSuccess(response, await this.officeFoldersService.getByUid("uid"));
} }
/** /**