Merge pull request #1422 from chandrikamohith/MIFOSX-1592
MIFOSX-1592 Fix for Global search api - group loans/savings search ar…
This commit is contained in:
@@ -33217,7 +33217,8 @@ GET https://DomainName/api/v1/search?query=000000111
|
||||
"entityName": "12-A Flat Loan",
|
||||
"entityType": "LOAN",
|
||||
"parentId": 65,
|
||||
"parentName": "aaaa aaaaa"
|
||||
"parentName": "aaaa aaaaa",
|
||||
"parentType": "client"
|
||||
}
|
||||
]
|
||||
</code>
|
||||
|
||||
+6
-1
@@ -18,9 +18,10 @@ public class SearchData {
|
||||
private final String parentName;
|
||||
private final String entityMobileNo;
|
||||
private final EnumOptionData entityStatus;
|
||||
private final String parentType;
|
||||
|
||||
public SearchData(final Long entityId, final String entityAccountNo, final String entityExternalId, final String entityName,
|
||||
final String entityType, final Long parentId, final String parentName,final String entityMobileNo, final EnumOptionData entityStatus) {
|
||||
final String entityType, final Long parentId, final String parentName, final String parentType, final String entityMobileNo, final EnumOptionData entityStatus) {
|
||||
|
||||
this.entityId = entityId;
|
||||
this.entityAccountNo = entityAccountNo;
|
||||
@@ -29,6 +30,7 @@ public class SearchData {
|
||||
this.entityType = entityType;
|
||||
this.parentId = parentId;
|
||||
this.parentName = parentName;
|
||||
this.parentType = parentType;
|
||||
this.entityMobileNo=entityMobileNo;
|
||||
this.entityStatus = entityStatus;
|
||||
}
|
||||
@@ -61,6 +63,9 @@ public class SearchData {
|
||||
return this.parentName;
|
||||
}
|
||||
|
||||
public String getParentType() {
|
||||
return this.parentType;
|
||||
}
|
||||
|
||||
public String getEntityMobileNo() {
|
||||
return this.entityMobileNo;
|
||||
|
||||
+19
-18
@@ -74,52 +74,52 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
|
||||
|
||||
final String union = " union ";
|
||||
final String clientExactMatchSql = " (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo "
|
||||
+ " , c.office_id as parentId, o.name as parentName, c.mobile_no as entityMobileNo,c.status_enum as entityStatusEnum "
|
||||
+ " , c.office_id as parentId, o.name as parentName, c.mobile_no as entityMobileNo,c.status_enum as entityStatusEnum, null as parentType "
|
||||
+ " from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :search or c.display_name like :search or c.external_id like :search or c.mobile_no like :search)) ";
|
||||
|
||||
final String clientMatchSql = " (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo "
|
||||
+ " , c.office_id as parentId, o.name as parentName,c.mobile_no as entityMobileNo, c.status_enum as entityStatusEnum "
|
||||
+ " , c.office_id as parentId, o.name as parentName,c.mobile_no as entityMobileNo, c.status_enum as entityStatusEnum, null as parentType "
|
||||
+ " from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :partialSearch and c.account_no not like :search) or "
|
||||
+ "(c.display_name like :partialSearch and c.display_name not like :search) or "
|
||||
+ "(c.external_id like :partialSearch and c.external_id not like :search)or"
|
||||
+ "(c.mobile_no like :partialSearch and c.mobile_no not like :search))";
|
||||
|
||||
final String loanExactMatchSql = " (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo "
|
||||
+ " , c.id as parentId, c.display_name as parentName, null as entityMobileNo, l.loan_status_id as entityStatusEnum "
|
||||
+ " from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and (l.account_no like :search or l.external_id like :search)) ";
|
||||
+ " , IFNULL(c.id,g.id) as parentId, IFNULL(c.display_name,g.display_name) as parentName, null as entityMobileNo, l.loan_status_id as entityStatusEnum, IF(g.id is null, 'client', 'group') as parentType "
|
||||
+ " from m_loan l left join m_client c on l.client_id = c.id left join m_group g ON l.group_id = g.id left join m_office o on o.id = c.office_id left join m_product_loan pl on pl.id=l.product_id where (o.hierarchy IS NULL OR o.hierarchy like :hierarchy) and (l.account_no like :search or l.external_id like :search)) ";
|
||||
|
||||
final String loanMatchSql = " (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo "
|
||||
+ " , c.id as parentId, c.display_name as parentName, null as entityMobileNo, l.loan_status_id as entityStatusEnum "
|
||||
+ " from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and "
|
||||
+ " , IFNULL(c.id,g.id) as parentId, IFNULL(c.display_name,g.display_name) as parentName, null as entityMobileNo, l.loan_status_id as entityStatusEnum, IF(g.id is null, 'client', 'group') as parentType "
|
||||
+ " from m_loan l left join m_client c on l.client_id = c.id left join m_group g ON l.group_id = g.id left join m_office o on o.id = c.office_id left join m_product_loan pl on pl.id=l.product_id where (o.hierarchy IS NULL OR o.hierarchy like :hierarchy) and "
|
||||
+ " ((l.account_no like :partialSearch and l.account_no not like :search) or (l.external_id like :partialSearch and l.external_id not like :search))) ";
|
||||
|
||||
final String savingExactMatchSql = " (select 'SAVING' as entityType, s.id as entityId, sp.name as entityName, s.external_id as entityExternalId, s.account_no as entityAccountNo "
|
||||
+ " , c.id as parentId, c.display_name as parentName, null as entityMobileNo, s.status_enum as entityStatusEnum "
|
||||
+ " from m_savings_account s join m_client c on s.client_id = c.id join m_office o on o.id = c.office_id join m_savings_product sp on sp.id=s.product_id "
|
||||
+ " where o.hierarchy like :hierarchy and (s.account_no like :search or s.external_id like :search)) ";
|
||||
+ " , IFNULL(c.id,g.id) as parentId, IFNULL(c.display_name,g.display_name) as parentName, null as entityMobileNo, s.status_enum as entityStatusEnum, IF(g.id is null, 'client', 'group') as parentType "
|
||||
+ " from m_savings_account s left join m_client c on s.client_id = c.id left join m_group g ON s.group_id = g.id left join m_office o on o.id = c.office_id left join m_savings_product sp on sp.id=s.product_id "
|
||||
+ " where (o.hierarchy IS NULL OR o.hierarchy like :hierarchy) and (s.account_no like :search or s.external_id like :search)) ";
|
||||
|
||||
final String savingMatchSql = " (select 'SAVING' as entityType, s.id as entityId, sp.name as entityName, s.external_id as entityExternalId, s.account_no as entityAccountNo "
|
||||
+ " , c.id as parentId, c.display_name as parentName, null as entityMobileNo, s.status_enum as entityStatusEnum "
|
||||
+ " from m_savings_account s join m_client c on s.client_id = c.id join m_office o on o.id = c.office_id join m_savings_product sp on sp.id=s.product_id "
|
||||
+ " where o.hierarchy like :hierarchy and (s.account_no like :partialSearch and s.account_no not like :search) or "
|
||||
+ " , IFNULL(c.id,g.id) as parentId, IFNULL(c.display_name,g.display_name) as parentName, null as entityMobileNo, s.status_enum as entityStatusEnum, IF(g.id is null, 'client', 'group') as parentType "
|
||||
+ " from m_savings_account s left join m_client c on s.client_id = c.id left join m_group g ON s.group_id = g.id left join m_office o on o.id = c.office_id left join m_savings_product sp on sp.id=s.product_id "
|
||||
+ " where (o.hierarchy IS NULL OR o.hierarchy like :hierarchy) and (s.account_no like :partialSearch and s.account_no not like :search) or "
|
||||
+ "(s.external_id like :partialSearch and s.external_id not like :search)) ";
|
||||
|
||||
final String clientIdentifierExactMatchSql = " (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, "
|
||||
+ " null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName,null as entityMobileNo, c.status_enum as entityStatusEnum "
|
||||
+ " null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName,null as entityMobileNo, c.status_enum as entityStatusEnum, null as parentType "
|
||||
+ " from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id "
|
||||
+ " where o.hierarchy like :hierarchy and ci.document_key like :search ) ";
|
||||
|
||||
final String clientIdentifierMatchSql = " (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, "
|
||||
+ " null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName,null as entityMobileNo ,c.status_enum as entityStatusEnum "
|
||||
+ " null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName,null as entityMobileNo ,c.status_enum as entityStatusEnum, null as parentType "
|
||||
+ " from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id "
|
||||
+ " where o.hierarchy like :hierarchy and (ci.document_key like :partialSearch and ci.document_key not like :search))";
|
||||
|
||||
final String groupExactMatchSql = " (select IF(g.level_id=1,'CENTER','GROUP') as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo "
|
||||
+ " , g.office_id as parentId, o.name as parentName, null as entityMobileNo, g.status_enum as entityStatusEnum "
|
||||
+ " , g.office_id as parentId, o.name as parentName, null as entityMobileNo, g.status_enum as entityStatusEnum, null as parentType "
|
||||
+ " from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name like :search or g.external_id like :search or g.id like :search )) ";
|
||||
|
||||
final String groupMatchSql = " (select IF(g.level_id=1,'CENTER','GROUP') as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo "
|
||||
+ " , g.office_id as parentId, o.name as parentName, null as entityMobileNo, g.status_enum as entityStatusEnum "
|
||||
+ " , g.office_id as parentId, o.name as parentName, null as entityMobileNo, g.status_enum as entityStatusEnum, null as parentType "
|
||||
+ " from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and (g.account_no like :partialSearch and g.account_no not like :search) or (g.display_name like :partialSearch and g.display_name not like :search) or(g.external_id like :partialSearch and g.external_id not like :search) or (g.id like :partialSearch and g.id not like :search)) ";
|
||||
|
||||
final StringBuffer sql = new StringBuffer();
|
||||
@@ -183,7 +183,8 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
|
||||
final String parentName = rs.getString("parentName");
|
||||
final String entityMobileNo = rs.getString("entityMobileNo");
|
||||
final Integer entityStatusEnum = JdbcSupport.getInteger(rs, "entityStatusEnum");
|
||||
|
||||
final String parentType = rs.getString("parentType");
|
||||
|
||||
EnumOptionData entityStatus = new EnumOptionData(0L, "", "");
|
||||
|
||||
if (entityType.equalsIgnoreCase("client") || entityType.equalsIgnoreCase("clientidentifier")) {
|
||||
@@ -200,7 +201,7 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
|
||||
entityStatus = LoanEnumerations.status(loanStatusEnumData);
|
||||
}
|
||||
|
||||
return new SearchData(entityId, entityAccountNo, entityExternalId, entityName, entityType, parentId, parentName,
|
||||
return new SearchData(entityId, entityAccountNo, entityExternalId, entityName, entityType, parentId, parentName, parentType,
|
||||
entityMobileNo, entityStatus);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user