From f5a94e721ae5a26f817f0df75065b64f1f192eb3 Mon Sep 17 00:00:00 2001 From: Li Jun <buli@deloitte.com.cn> Date: 星期一, 28 三月 2022 21:43:51 +0800 Subject: [PATCH] PIPLFunctionDeploy0328 --- force-app/main/default/classes/DeveloperUtility.cls | 75 ++++++++++++++++++++++++++++++++++++- 1 files changed, 72 insertions(+), 3 deletions(-) diff --git a/force-app/main/default/classes/DeveloperUtility.cls b/force-app/main/default/classes/DeveloperUtility.cls index f8f0662..a611cc1 100644 --- a/force-app/main/default/classes/DeveloperUtility.cls +++ b/force-app/main/default/classes/DeveloperUtility.cls @@ -1,6 +1,16 @@ public class DeveloperUtility { - public static List<HTTPResponse> CreateFields(string sobject_name,string [] fields){ + /**public static List<HTTPResponse> CreateFields(string sobject_name,string [] fields, boolean create_field,boolean create_config){ + + PI_Policy_Configuration__c ppc = null; + if(create_config){ + List<PI_Policy_Configuration__c> ppcs = [select id from PI_Policy_Configuration__c where Sobject_Type__c = :sobject_name]; + if(ppcs.size()>0){ + ppc = ppcs[0]; + } + } + + List<PI_Field_Policy_Detail__c> ds = new List<PI_Field_Policy_Detail__c>(); List<HTTPResponse> results = new List<HTTPResponse>(); for(string f : fields){ string old_label = f.removeEnd('__c').replace('_',' '); @@ -10,8 +20,39 @@ system.debug('old_label='+old_label); system.debug('label='+label); system.debug('name='+name); - results.add(CreateField(sobject_name,label,name,description,'Text')); + if(create_field){ + system.debug(CreateField(sobject_name,label,name,description,'Text')); + } + + + if(create_config){ + PI_Field_Policy_Detail__c d = new PI_Field_Policy_Detail__c(); + d.SF_Field_API_Name__c = f; + d.SF_Field_Encrypted_API__c = name; + d.AWS_Field_API__c = f; + d.AWS_Encrypted_Field_API__c = name; + d.Field_Type__c = 'String'; + d.Enable_Encrypt__c = true; + if(ppc!=null){ + d.PI_Policy_Configuration__c = ppc.Id; + } + + ds.add(d); + } + } + + if(ppc==null){ + ppc = new PI_Policy_Configuration__c(); + ppc.Sobject_Type__c = sobject_name; + insert ppc; + for(PI_Field_Policy_Detail__c d : ds){ + d.PI_Policy_Configuration__c = ppc.Id; + } + } + + insert ds; + return results; } @@ -54,9 +95,37 @@ req.setBody(b); req.setCompressed(false); - req.setEndpoint('https://ocsm--pipl.my.salesforce.com/services/Soap/m/25.0'); + req.setEndpoint('https://'+System.URL.getOrgDomainUrl().getHost()+'/services/Soap/m/25.0'); HTTPResponse resp = h.send(req); + System.debug(resp.getStatus()); System.debug(resp.getBody()); return resp; } + + public static string ToolingQuery(string query){ + + system.debug('query='+query); + String baseURL = 'https://'+System.URL.getOrgDomainUrl().getHost()+'/services/data/v41.0/tooling/query?q='+ query.replace(' ', '+'); + HttpResponse resp = null; + HttpRequest req = new HttpRequest(); + req.setMethod('GET'); + + req.setHeader('Authorization', 'Bearer ' + UserInfo.getsessionid()); + req.setEndpoint(baseURL); + + Http client = new Http(); + resp = client.send(req); + + system.debug(resp.getStatus()); + system.debug(resp.getStatusCode()); + if(resp.getStatus() == 'OK'){ + string s = resp.getBody(); + system.debug(resp.getBody()); + return s; + }else{ + system.debug('status is not ok,error:'+resp.getBody()); + return null; + } + + }*/ } \ No newline at end of file -- Gitblit v1.9.1