buli
2023-07-11 80a3f59e2d3df07805bc67e329300b8de90a5b3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
    }
}