From 0c4796706fc9473d069b620321a54b20a119906c Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 11 七月 2023 14:16:44 +0800
Subject: [PATCH] Merge branch 'LEXUpgrade2023-Deloitte'

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

diff --git a/force-app/main/default/classes/LexNewAndEditContactPIPLController.cls b/force-app/main/default/classes/LexNewAndEditContactPIPLController.cls
new file mode 100644
index 0000000..5844afa
--- /dev/null
+++ b/force-app/main/default/classes/LexNewAndEditContactPIPLController.cls
@@ -0,0 +1,59 @@
+public with sharing class LexNewAndEditContactPIPLController {
+    public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
+    // 瀛楁淇℃伅
+    public static Map<string, SObjectField> fieldMap = new Map<string, SObjectField>();
+
+    @AuraEnabled
+    public static ResponseBodyLWC initData(Id rid, String recordTypeId, String sobjectType, String accid) {
+        ResponseBodyLWC res = new ResponseBodyLWC();
+        Map<String, object> data = new Map<String, object>();
+        res.entity = data;
+
+        Boolean isDoctor = true;
+        string s = null;
+
+        //濡傛灉鏈夎褰曠被鍨嬶紝鍒ゆ柇鏄笉鏄尰闄㈢被鍨�
+        if (String.isNotBlank(recordTypeId)) {
+            System.debug('recordTypeId = ' + recordTypeId);
+            s = Schema.SObjectType.Contact.getRecordTypeInfosById().get(recordTypeId).getDeveloperName();
+            //璇存槑鏃犻渶鍔犲瘑
+            if (s == 'Agency' || s == 'Internal_staff') {
+                isDoctor = false;
+                data.put('isDoctor', isDoctor);
+                return new ResponseBodyLWC('Success', 200, '', data);
+            }
+        }
+        //璇存槑鏃犻渶鍔犲瘑
+        if (String.isNotBlank(accid)) {
+            List<Account> accs = [SELECT RecordType.DeveloperName FROM account WHERE id = :accid];
+            if (accs.size() > 0) {
+                s = accs[0].RecordType.DeveloperName;
+                if (s == 'Office' || s == 'AgencyContact' || s == 'Agency') {
+                    isDoctor = false;
+                    data.put('isDoctor', isDoctor);
+                    return new ResponseBodyLWC('Success', 200, '', data);
+                }
+            }
+        }
+
+        //璇存槑鏃犻渶鍔犲瘑
+        if (String.isNotBlank(rid)) {
+            List<Contact> contact = [SELECT Id, RecordTypeId FROM Contact WHERE Id = :rid];
+            if (String.isNotBlank(contact[0].RecordTypeId)) {
+                s = Schema.SObjectType.Contact.getRecordTypeInfosById().get(contact[0].RecordTypeId).getDeveloperName();
+                if (s == 'Agency' || s == 'Internal_staff') {
+                    isDoctor = false;
+                    data.put('isDoctor', isDoctor);
+                    return new ResponseBodyLWC('Success', 200, '', data);
+                }
+            }
+        }
+        ResponseBodyLWC rbl = LexNewAndEditBasePIPLController.initData(rid, recordTypeId, sobjectType);
+        if (rbl.status == 'Success') {
+            data = (Map<String, Object>) rbl.entity;
+            data.put('isDoctor', isDoctor);
+            rbl.entity = data;
+        }
+        return rbl;
+    }
+}

--
Gitblit v1.9.1