Skip to content

Commit

Permalink
API modification to fetch beneficiaries based on villageId list inste…
Browse files Browse the repository at this point in the history
…ad of single Id. (#5)

* Modified API to sync beneficiaries based on villageId list instead of a single villageId.
  • Loading branch information
shreypatidar-beehyv authored Sep 12, 2023
1 parent b7c1856 commit b84461f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ public class IdentityController {

logger.info("IdentityController.getBeneficiary - end");
} catch (Exception e) {
logger.error("error in beneficiary search by Family Id : " + e.getLocalizedMessage());
response = getErrorResponseString("error in beneficiary search by village Id and last sync date : " + e.getLocalizedMessage(),
logger.error("error in beneficiary search by village Ids and last sync date : " + e.getLocalizedMessage());
response = getErrorResponseString("error in beneficiary search by village Ids and last sync date : " + e.getLocalizedMessage(),
5000, "failure", "");
}
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
package com.iemr.common.identity.dto;

import lombok.Data;
import java.util.List;

@Data
public class SearchSyncDTO {

private Long lastModifiedDate;
private Integer villageID;
private List<Integer> villageID;

}
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public List<Object[]> getBenMappingByBenDetailsIds(@Param("benDetailsIds") List<
public List<Object[]> getBenMappingByVanSerialNo(@Param("benMapIds") BigInteger benMapIds,
@Param("vanID") Integer vanID);

@Query(value = "select m from MBeneficiarymapping m where m.mBeneficiaryaddress.permVillageId = :villageID and "
@Query(value = "select m from MBeneficiarymapping m where m.mBeneficiaryaddress.permVillageId IN :villageIDs and "
+ "(m.mBeneficiaryaddress.lastModDate > :lastModDate or m.mBeneficiarycontact.lastModDate > :lastModDate "
+ "or m.mBeneficiarydetail.lastModDate > :lastModDate ) order by m.benMapId Desc")
List<MBeneficiarymapping> findByBeneficiaryDetailsByVillageIDAndLastModifyDate(@Param("villageID") int villageID, @Param("lastModDate") Timestamp lastModifiedDate);
List<MBeneficiarymapping> findByBeneficiaryDetailsByVillageIDAndLastModifyDate(@Param("villageIDs") List<Integer> villageID, @Param("lastModDate") Timestamp lastModifiedDate);

}
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,12 @@ public List<BeneficiariesDTO> searhBeneficiaryByFamilyId(String familyId)
return beneficiaryList;
}

public List<BeneficiariesDTO> searchBeneficiaryByVillageIdAndLastModifyDate(Integer villageID, Timestamp lastModifiedDate) {
public List<BeneficiariesDTO> searchBeneficiaryByVillageIdAndLastModifyDate(List<Integer> villageIDs, Timestamp lastModifiedDate) {

List<BeneficiariesDTO> beneficiaryList = new ArrayList<BeneficiariesDTO>();
try {
// find benmap ids
List<MBeneficiarymapping> benMappingsList = mappingRepo.findByBeneficiaryDetailsByVillageIDAndLastModifyDate(villageID, lastModifiedDate);
List<MBeneficiarymapping> benMappingsList = mappingRepo.findByBeneficiaryDetailsByVillageIDAndLastModifyDate(villageIDs, lastModifiedDate);
if (benMappingsList != null && !benMappingsList.isEmpty()){

for (MBeneficiarymapping benMapOBJ : benMappingsList) {
Expand All @@ -521,7 +521,7 @@ public List<BeneficiariesDTO> searchBeneficiaryByVillageIdAndLastModifyDate(Inte
}
} catch (Exception e) {
logger.error(
"error in beneficiary search to sync to CHO App with villageID: " + villageID + " error : " + e.getLocalizedMessage());
"error in beneficiary search to sync to CHO App with villageIDs: " + villageIDs + " error : " + e.getLocalizedMessage());
}
return beneficiaryList;
}
Expand Down

0 comments on commit b84461f

Please sign in to comment.