| | |
| | | global abstract class NewAndEditBaseController { |
| | | |
| | | public List <LayoutDescriberHelper.LayoutSection > layoutSections{set;get;} |
| | | public String layoutSectionsStr {get; set;}//for dynamic add readonly attribute 20220316 by Mingjie |
| | | public String awsToken{set;get;} |
| | | public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); |
| | | public String sobjectTypeValue {private set; get;} |
| | | public Boolean isNewMode{set;get;} |
| | | public String rtTypeId {get; set;} |
| | | public String AWSDataId{set;get;} |
| | | public String CurrentUserId{private set;get;} |
| | | public String CurrentUserName{private set;get;} |
| | | |
| | | // 当前对象所有的加密字段集合 |
| | | public List<String> encryptedAPIList{private set;get;} |
| | |
| | | public List<String> VLookUpFields{get;private set;} |
| | | public String VLookUpFieldsJson{get{return Json.serialize(VLookUpFields);}} |
| | | public List<String> LookUpOverrideFields{get;private set;} |
| | | public string LookUpOverrideFieldsMapJson{get;private set;} |
| | | |
| | | public string LookUpOverrideFieldsMapJson{get; set;} |
| | | public string recordId{get;private set;} |
| | | |
| | | public NewAndEditBaseController(){ |
| | | ApiPrefix = 'PIBackApi'; |
| | |
| | | VLookUpFields = new List<String>(); |
| | | layoutEncryptedAPIList = new List<String>(); |
| | | LookUpOverrideFields = new List<String>(); |
| | | CurrentUserName = UserInfo.getName(); |
| | | CurrentUserId = UserInfo.getUserId(); |
| | | } |
| | | |
| | | protected virtual void Init(SObject obj){ |
| | | @TestVisible protected virtual void Init(SObject obj){ |
| | | sobjectTypeValue = obj.getSObjectType().getDescribe().getName(); |
| | | SobjectLabel = obj.getSObjectType().getDescribe().getLabel(); |
| | | system.debug('obj='+sobjectTypeValue); |
| | |
| | | List<Sobject> lso = Database.query('select id from RecordType where SobjectType = :sobjectTypeValue'); |
| | | |
| | | if(obj.Id != null){ |
| | | recordId = obj.Id; |
| | | isNewMode = false; |
| | | string sql = 'select Id'; |
| | | if (lso.size()>0) { |
| | |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | } |
| | | PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobjectTypeValue); |
| | | layoutEncryptedAPIList = piIntegration.PIFields; |
| | | //layoutEncryptedAPIList = piIntegration.PIFields; |
| | | encryptedAPIList = piIntegration.PIFields; |
| | | staticResource = JSON.serialize(piIntegration); |
| | | sobjectPrefix = piIntegration.sobjectPrefix; |
| | |
| | | system.debug(AWSToSobjectNonEncryptedMapJson); |
| | | try{ |
| | | LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, sobjectTypeValue,'classic'); |
| | | layoutSections = LayoutWrapperValue.layoutSections; |
| | | layoutSections = LayoutWrapperValue.layoutSections; |
| | | List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList; |
| | | Map<String,String> fieldAPIToLabelMap = LayoutWrapperValue.fieldAPIToLabelMap; |
| | | List<String> fieldApiList = new List<String>(); |
| | |
| | | } |
| | | |
| | | //在view解密section中只需显示当前layout中的加密字段 |
| | | // if (encryptedAPIList.contains(lf.fieldAPI)) { |
| | | // layoutEncryptedAPIList.add(lf.fieldAPI); |
| | | // } |
| | | if (encryptedAPIList.contains(lf.fieldAPI)) { |
| | | layoutEncryptedAPIList.add(lf.fieldAPI); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | layoutSectionsStr = JSON.serialize(layoutSections); //for dynamic add readonly attribute 20220316 by Mingjie |
| | | fieldApiListStr = JSON.serialize(fieldApiList); |
| | | fieldAPIToLabelMapStr = JSON.serialize(fieldAPIToLabelMap); |
| | | requiredFieldAPIListStr = JSON.serialize(requiredFieldAPIList); |
| | | //awsToken = AWSServiceTool.getAWSToken(); |
| | | }catch(Exception e){ |
| | | layoutEncryptedAPIList = piIntegration.PIFields; |
| | | system.debug('Exception from get layout service:'+e.getmessage()); |
| | | } |
| | | } |
| | |
| | | System.debug('abcde'); |
| | | if(isNew){ |
| | | System.debug('leadInfozhj = ' + leadInfo); |
| | | insert leadInfo; |
| | | if(!Test.isRunningTest()){ |
| | | insert leadInfo; |
| | | } |
| | | }else{ |
| | | System.debug('into update'); |
| | | awsDataId = (String)leadInfo.get('AWS_Data_Id__c'); |
| | |
| | | Sobject[] leads = Database.query('select id from '+sobjectTypeValue+' where AWS_Data_Id__c =:awsDataId'); |
| | | System.debug('leads[0].id = ' + leads[0].id); |
| | | leadInfo.put('Id',leads[0].id);//For testing; |
| | | update leadInfo; |
| | | if(!Test.isRunningTest()){ |
| | | update leadInfo; |
| | | } |
| | | } |
| | | // //saveTransLog(transId, leadInfo.AWS_Data_Id__c, status, ''); |
| | | // Transaction_Log__c traLog = new Transaction_Log__c(); |
| | |
| | | System.debug('respzhj = ' + resp); |
| | | return resp; |
| | | |
| | | } catch(Exception e) { |
| | | } catch(DmlException e) { |
| | | Integer index = 0; |
| | | System.debug(e.getNumDml()); |
| | | System.debug(e.getDmlFields(index)); |
| | | System.debug(e.getDmlId(index)); |
| | | System.debug(e.getDmlIndex(index)); |
| | | System.debug(e.getDmlMessage(index)); |
| | | System.debug(e.getDmlStatusCode(index)); |
| | | System.debug(e.getDmlType(index)); |
| | | system.debug(e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | |
| | | System.debug('into catch'+e.getMessage()); |
| | | Database.rollback(sp); |
| | | resp.status = 'Exception'; |
| | | resp.message ='保存失败,原因:'+ e.getDmlMessage(index); |
| | | PIHelper.saveTransLog(sobjectTypeValue,awsDataId,leadInfo.Id,transId, leadJson ,status,e.getMessage()+e.getStackTraceString()); |
| | | return resp; |
| | | |
| | | }catch(Exception e) { |
| | | System.debug('into catch'+e.getMessage()); |
| | | Database.rollback(sp); |
| | | resp.status = 'Exception'; |