From 02ddc35714cbd1688b7cb057f770f1410de79dab Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 11 三月 2022 12:19:33 +0800 Subject: [PATCH] PIPL Updated Code 20220311 --- force-app/main/default/classes/AWSServiceTool.cls | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 39 insertions(+), 9 deletions(-) diff --git a/force-app/main/default/classes/AWSServiceTool.cls b/force-app/main/default/classes/AWSServiceTool.cls index 85eaf80..0c2e0ba 100644 --- a/force-app/main/default/classes/AWSServiceTool.cls +++ b/force-app/main/default/classes/AWSServiceTool.cls @@ -9,14 +9,44 @@ * */ public without sharing class AWSServiceTool { public static String getAWSToken(){ - String app_id = '6LzizcRf7h8yLx28'; - String app_secret = 'UkLohQcHNjg164SdRc7gnS4rgu4d7FjINM3mtzRbyTS6IrUP5V'; - String url = 'https://52.83.101.205/api/token/getToken?app_id=' + app_id + '&app_secret=' + app_secret; - HttpRequest req = new HttpRequest(); - req.setEndpoint(url); - req.setMethod('GET'); - Http h = new Http(); - HttpResponse res = h.send(req); - return res.getBody(); + 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) { + System.debug('AWS_Integration_Info__mdt娌¢厤缃�'); + return null; + } + String awsAppId = awsConfiguration.App_Id__c; + String awsAppSecret = awsConfiguration.App_Secret__c; + Http http = new Http(); + HttpRequest request = new HttpRequest(); + String url = awsConfiguration.Token_URL__c; + request.setEndpoint(url); + request.setMethod('GET'); + 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