liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
public with sharing class lexOpportunitySpecialApplyController {
    @AuraEnabled
    public static InitData initForSpecSubmitButton(String recordId){
        InitData res = new InitData();
        try {
            OpportunitySpecialApply__c opp = [
                select
                Apply_Reason__c,
                Is_upload_file__c,
                Status__c
                from OpportunitySpecialApply__c where Id =: recordId
            ];
            res.applyReason = opp.Apply_Reason__c;
            res.isUploadFile = opp.Is_upload_file__c;
            res.status = opp.Status__c;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
   @AuraEnabled
   public static string updateForSpecSubmitButton(String recordId){
    OpportunitySpecialApply__c opp = new OpportunitySpecialApply__c();
    try {
        opp.Id = recordId;
        opp.Status__c = lexLightingButtonConstant.STATUS_OPPORTUNITY_SPECIAL_APPLY_SUBMIT;
        update opp;
        return '';
    } catch (Exception e) {
        if (e.getMessage().contains(',')) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String exc = '' + e.getMessage();
            Integer left = exc.indexOf(':') + 1;
            Integer right = exc.lastIndexOf(':');
            String str = exc.substring(left,right);
            left = str.indexOf(',') +  1;
            String newStr = str.substring(left);
            return newStr;
        }else {
            return e.getMessage();   
        } 
    }
   } 
    public class InitData{
        @AuraEnabled
        public String applyReason;
        @AuraEnabled
        public Boolean isUploadFile;
        @AuraEnabled
        public String status;
    }
}