From b823c7f3569cf9368e2245846e918f78f32e903a Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期五, 15 四月 2022 11:38:47 +0800
Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlympusSSBG

---
 force-app/main/default/classes/AWSServiceTool.cls |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/AWSServiceTool.cls b/force-app/main/default/classes/AWSServiceTool.cls
index 049cffd..5f10b3e 100644
--- a/force-app/main/default/classes/AWSServiceTool.cls
+++ b/force-app/main/default/classes/AWSServiceTool.cls
@@ -8,6 +8,21 @@
  * 
  * */
 public without sharing class AWSServiceTool {
+    public static List<Contact>  getNoPIContact(String searchContactName,String accountId){
+        if(searchContactName!='' || accountId!=''){
+            String noPISQL = 'select Id,Name,Email,Phone,Account.Name,MobilePhone from Contact where Account_Record_Type_DeveloperName__c in('+'\'Agency\''+','+'\'Dealer\''+')';
+            if(String.isNotEmpty(accountId)){
+                noPISQL += ' and AccountId=\''+accountId+'\'';
+            }
+            if(String.isNotEmpty(searchContactName)){
+                noPISQL += ' and Name like \'%'+searchContactName+'%\'';
+            }
+            system.debug('noPISQL = ' + noPISQL);
+            List<Contact> partnerContactList = Database.query(noPISQL);
+            return partnerContactList;
+        }
+        return new List<Contact>();
+    }
     public static String getAWSToken(){
         AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt  WHERE DeveloperName = 'AWS_Default_Configuration'];
         if (awsConfiguration == null) {
@@ -21,9 +36,35 @@
         String url = awsConfiguration.Token_URL__c;
         request.setEndpoint(url);
         request.setMethod('GET');
+        if(Test.isRunningTest()){
+            return 'UTToken';
+        }
         HttpResponse response = http.send(request);
         Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
         String token = (String)results.get('object');
         return token;
     }
+    @future(callout=true)
+    public static void deleteFileAddress(Set<String> fileAddressIds){
+        //1. Get file address id
+        system.debug('fileAddressId = '+ JSON.serialize(fileAddressIds));
+        PIHelper.PIIntegration documentPI=PIHelper.getPIIntegrationInfo('Document');
+        //2. Delete aws file doucment and post aws service
+        Http http = new Http();
+        HttpRequest request = new HttpRequest();
+        String url = documentPI.deleteUrl;
+        request.setEndpoint(url);
+        request.setMethod('POST');
+        request.setHeader('pi-token',documentPI.token);
+        request.setHeader('Content-Type', 'application/json');
+        request.setBody(JSON.serialize(fileAddressIds));
+        HttpResponse response = http.send(request);
+        system.debug('response = ' + response);
+        if(response.getStatusCode() == 200){
+            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
+            if(results.get('status')=='0'){
+                System.debug('鎴愬姛鍒犻櫎');
+            }
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1