fixed description template code validation

This commit is contained in:
CITE\spapacharalampous 2024-08-29 18:03:06 +03:00
parent 1149668e2f
commit 6e8eccecb1
1 changed files with 3 additions and 0 deletions

View File

@ -226,6 +226,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
.groupIds(data.getGroupId())
.count();
if (activeDescriptionTemplatesForTheGroup > 0) throw new MyApplicationException("Description template group id is in use please use new version endpoint");
Long descriptionTemplateCodes = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().codes(model.getCode()).count();
if (descriptionTemplateCodes > 0) throw new MyValidationException(this.errors.getDescriptionTemplateCodeExists().getCode(), this.errors.getDescriptionTemplateCodeExists().getMessage());
}
this.updateVersionStatusAndSave(data, previousStatus, data.getStatus());