public without sharing class SearchLeadController {
|
public String searchKeyWord{set;get;}
|
public String staticResource {get; set;}
|
public String leadAWSIds {set;get;}
|
public String leadsInfo {set;get;}
|
public String PIPL_Search_Contact_Label{set;get;}
|
public SearchLeadController() {
|
// String accountId = ApexPages.currentPage().getParameters().get('accountId');
|
PIPL_Search_Contact_Label = Label.PIPL_Search_Contact_Label;
|
//1. Query Contact by accountId
|
List<Lead> leadList = new List<Lead>();
|
// system.debug('Account Id from Front-end:'+accountId);
|
// if(String.isNotBlank(accountId) && String.isNotEmpty(accountId)){
|
// leadList = new List<Lead>([select Id,AWS_Data_Id__c from Lead where AccountId=:accountId and AWS_Data_Id__c!='']);
|
// }
|
leadList = new List<Lead>([select Id,AWS_Data_Id__c from Lead where AWS_Data_Id__c!='']);
|
//2. Prepare the Contact Info
|
Map<String,Lead> awsIdToLeadMap = new Map<String,Lead>();
|
List<String> leAWSIds = new List<String>();
|
for(Lead le:leadList){
|
leAWSIds.add(le.AWS_Data_Id__c);
|
awsIdToLeadMap.put(le.AWS_Data_Id__c,le);
|
}
|
leadsInfo = JSON.serialize(awsIdToLeadMap);
|
leadAWSIds = JSON.serialize(leAWSIds);
|
staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Lead'));
|
}
|
|
@RemoteAction
|
public static Response searchLeads(String awsLeadIds) {
|
Response resp = new Response();
|
resp.status = 'fail';
|
if(String.isBlank(awsLeadIds)||String.isEmpty(awsLeadIds)){
|
return resp;
|
}
|
List<String> awsDataIds = (List<String>) JSON.deserialize(awsLeadIds, List<String>.class);
|
Map<String,Lead> awsIdToLeadMapTemp = new Map<String,Lead>();
|
List<Lead> leadListTemp = new List<Lead>([select Id,AWS_Data_Id__c from Lead where AWS_Data_Id__c in:awsDataIds]);
|
for(Lead le:leadListTemp){
|
awsIdToLeadMapTemp.put(le.AWS_Data_Id__c,le);
|
}
|
if(awsIdToLeadMapTemp.keySet().size()>0){
|
resp.status = 'success';
|
resp.message = JSON.serialize(awsIdToLeadMapTemp);
|
}
|
return resp;
|
}
|
|
public class Response{
|
public String message{set;get;}
|
public String status{set;get;}
|
}
|
}
|