Fixed issue in company document get endpoint
This commit is contained in:
@@ -333,6 +333,11 @@ public class CompanyDocumentDao {
|
|||||||
|
|
||||||
predicate = builder.and(predicate, builder.isFalse(root.get("isDeleted")));
|
predicate = builder.and(predicate, builder.isFalse(root.get("isDeleted")));
|
||||||
|
|
||||||
|
predicate = builder.and(
|
||||||
|
predicate,
|
||||||
|
builder.notEqual(root.get("status"), CompanyDocumentStatusEnum.EXPIRED.getValue())
|
||||||
|
);
|
||||||
|
|
||||||
if (typeEnum != null) {
|
if (typeEnum != null) {
|
||||||
if (typeEnum == CompanyDocumentTypeEnum.COMPANY_DOCUMENT) {
|
if (typeEnum == CompanyDocumentTypeEnum.COMPANY_DOCUMENT) {
|
||||||
// Case 1: Fetch only COMPANY_DOCUMENT type documents for the given company
|
// Case 1: Fetch only COMPANY_DOCUMENT type documents for the given company
|
||||||
@@ -346,7 +351,7 @@ public class CompanyDocumentDao {
|
|||||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}else {
|
||||||
// Case 3: If typeEnum is null, fetch all documents for the company and personal documents for the user
|
// Case 3: If typeEnum is null, fetch all documents for the company and personal documents for the user
|
||||||
Predicate companyPredicate = builder.equal(root.get("companyId"), companyId);
|
Predicate companyPredicate = builder.equal(root.get("companyId"), companyId);
|
||||||
Predicate personalPredicate = builder.and(
|
Predicate personalPredicate = builder.and(
|
||||||
@@ -354,7 +359,7 @@ public class CompanyDocumentDao {
|
|||||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||||
);
|
);
|
||||||
predicate = builder.and(predicate, builder.or(companyPredicate, personalPredicate));
|
predicate = builder.and(predicate, builder.or(companyPredicate, personalPredicate));
|
||||||
predicate = builder.equal(root.get("status"), CompanyDocumentStatusEnum.VALID.getValue());
|
}
|
||||||
return predicate;
|
return predicate;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user