From 01f207d979d6be17c8cdec293feab48828c0ec3e Mon Sep 17 00:00:00 2001 From: 黄千龙 <huangqianlong@prec-tech.com> Date: 星期五, 08 四月 2022 14:22:52 +0800 Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlyMEBG --- force-app/main/default/classes/SearchContactController.cls | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 46 insertions(+), 14 deletions(-) diff --git a/force-app/main/default/classes/SearchContactController.cls b/force-app/main/default/classes/SearchContactController.cls index f84e347..d6d46b2 100644 --- a/force-app/main/default/classes/SearchContactController.cls +++ b/force-app/main/default/classes/SearchContactController.cls @@ -13,15 +13,31 @@ public String contactAWSIds {set;get;} public String contactsInfo {set;get;} public String PIPL_Search_Contact_Label{set;get;} + public String aId{set;get;} + public static Boolean checkNullString(String inputString){ + if(String.isEmpty(inputString)||String.isBlank(inputString)){ + return true; + } + return false; + } public SearchContactController() { String accountId = ApexPages.currentPage().getParameters().get('accountId'); + searchKeyWord = ApexPages.currentPage().getParameters().get('searchContactKeyWord'); + aId = accountId; PIPL_Search_Contact_Label = Label.PIPL_Search_Contact_Label; //1. Query Contact by accountId List<Contact> conList = new List<Contact>(); system.debug('Account Id from Front-end:'+accountId); - if(String.isNotBlank(accountId) && String.isNotEmpty(accountId)){ - conList = new List<Contact>([select Id,AWS_Data_Id__c from Contact where AccountId=:accountId and AWS_Data_Id__c!='']); - } + if(checkNullString(accountId)&&checkNullString(searchKeyWord)){ + conList = new List<Contact>(); + }else{ + if(checkNullString(accountId)){ + conList = new List<Contact>(); + }else { + conList = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AccountId=:accountId and AWS_Data_Id__c!='']); + } + + } //2. Prepare the Contact Info Map<String,Contact> awsIdToContactMap = new Map<String,Contact>(); List<String> conAWSIds = new List<String>(); @@ -35,21 +51,36 @@ } @RemoteAction - public static Response searchContacts(String awsContactIds) { + public static Response searchContacts(String awsContactIds,String searchContactName,String accountId) { + system.debug('awsContactIds = ' + awsContactIds); Response resp = new Response(); resp.status = 'fail'; - if(String.isBlank(awsContactIds)||String.isEmpty(awsContactIds)){ - return resp; - } - List<String> awsDataIds = (List<String>) JSON.deserialize(awsContactIds, List<String>.class); Map<String,Contact> awsIdToContactMapTemp = new Map<String,Contact>(); - List<Contact> conListTemp = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AWS_Data_Id__c in:awsDataIds]); - for(Contact con:conListTemp){ - awsIdToContactMapTemp.put(con.AWS_Data_Id__c,con); + if(!checkNullString(awsContactIds)){ + List<String> awsDataIds = (List<String>) JSON.deserialize(awsContactIds, List<String>.class); + List<Contact> conListTemp = new List<Contact>(); + if(!checkNullString(accountId)){ + conListTemp = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AccountId=:accountId and AWS_Data_Id__c in:awsDataIds]); + }else { + conListTemp = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AWS_Data_Id__c in:awsDataIds]); + } + for(Contact con:conListTemp){ + awsIdToContactMapTemp.put(con.AWS_Data_Id__c,con); + } } - if(awsIdToContactMapTemp.keySet().size()>0){ + System.debug('awsIdToContactMapTemp = ' + awsIdToContactMapTemp); + Map<String,Contact> noPIContactMapTemp = new Map<String,Contact>(); + List<Contact> partnerContactList = AWSServiceTool.getNoPIContact(searchContactName,accountId); + System.debug('partnerContactList = ' + partnerContactList); + if(partnerContactList.size()>0){ + for(Contact con:partnerContactList){ + noPIContactMapTemp.put(con.Id,con); + } + } + if(awsIdToContactMapTemp.keySet().size()>0 ||noPIContactMapTemp.keySet().size()>0){ resp.status = 'success'; - resp.message = JSON.serialize(awsIdToContactMapTemp); + resp.message = JSON.serialize(awsIdToContactMapTemp);// PI contact info + resp.noPIContactList = JSON.serialize(noPIContactMapTemp);//NoPI contact info } return resp; } @@ -58,7 +89,7 @@ public static Response searchContactsNoPI(String contactName) { Response resp = new Response(); resp.status = 'fail'; - List<Contact> conListTemp = new List<Contact>([select Id,Name,Account.Name,Phone,Email from Contact where Name like :contactName]); + List<Contact> conListTemp = new List<Contact>([select Id,Name,Account.Name,Phone,Email,MobilePhone from Contact where Name like :contactName]); if(conListTemp.size() > 0){ resp.status = 'success'; resp.message = JSON.serialize(conListTemp); @@ -69,5 +100,6 @@ public class Response{ public String message{set;get;} public String status{set;get;} + public String noPIContactList{set;get;} } } \ No newline at end of file -- Gitblit v1.9.1