Implemented company in application
This commit is contained in:
@@ -42,20 +42,20 @@ public class CompanyDao {
|
||||
}
|
||||
|
||||
private void validateCompany(CompanyRequest companyRequest) {
|
||||
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(companyRequest.getEmail()))
|
||||
&& Boolean.FALSE.equals(Utils.isValidEmail(companyRequest.getEmail()))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_EMAIL));
|
||||
}
|
||||
if(StringUtils.isEmpty(companyRequest.getVatNumber())) {
|
||||
if (StringUtils.isEmpty(companyRequest.getVatNumber())) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.VATNUMBER_MANDATORY));
|
||||
}
|
||||
if(companyRepository.existsByVatNumber(companyRequest.getVatNumber())) {
|
||||
if (companyRepository.existsByVatNumber(companyRequest.getVatNumber())) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.VATNUMBER_ALREADY_EXISTS));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private UserWithCompanyEntity createUserWithCompanyRelation(UserEntity userEntity, CompanyEntity companyEntity) {
|
||||
@@ -153,4 +153,9 @@ public class CompanyDao {
|
||||
return list.stream().map(this::convertCompanyEntityToCompanyResponse).toList();
|
||||
}
|
||||
|
||||
public UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId) {
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyId(userId, companyId).orElseThrow(() -> new CustomValidationException(Status.UNAUTHORIZED,
|
||||
Translator.toLocale(GepafinConstant.UNAUTHORIZED)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user