public with sharing class lexSubAuthorizedButtonController {
    //button 取消
    @AuraEnabled
    public static SubAuthorized__c init(String recordId){
        SubAuthorized__c res = new SubAuthorized__c();
        try{
            res = [SELECT Status__c 
                    From SubAuthorized__c
                        WHERE Id = : recordId];
        }
        catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }

    @AuraEnabled
    public static String updateStatuById(String Id){
        try{
            SubAuthorized__c res = new SubAuthorized__c();
            res.Id = Id;
            res.Status__c = '已取消';
            update res;
            return 'success';
        }
        catch(Exception e){
            String messageText='';
            if(e.getMessage().contains(':')){
                String eMessage =e.getMessage();
                Integer left = eMessage.indexOf(',')+1;
                Integer right= eMessage.lastIndexOf('：')+1;
                if(right>eMessage.length()||right<=left){
                    right=eMessage.length();
                }
                String mes=eMessage.substring(left,right);
                messageText = mes;
                return messageText;
            }else{
                messageText=e.getMessage();
                return messageText;
            }  
        }
    }
}