19626
2023-10-09 25f056535350a0b80bad50d2cc45311998e5d1cd
force-app/main/default/classes/lexAccountController.cls
@@ -1,5 +1,20 @@
public with sharing class lexAccountController {
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new InitData();
        try {
            Account acc = [
                select
                Name
                from Account where Id =: recordId
            ];
            res.name = acc.Name;
        } catch (Exception e) {
            System.debug(e.getMessage());
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForNewSolutonProButton(String recordId){
        InitData res = new InitData();
        try {
@@ -15,7 +30,7 @@
            res.hospitalId = acc.Hospital__r.Id;
            res.hospitalOCMCategory = acc.Hospital__r.OCM_Category__c;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
            System.debug(e.getMessage());
        }
        return res;
    }
@@ -25,11 +40,55 @@
        try {
           res.recordTypeId = Schema.SObjectType.Account_Number_of_case__c.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_OTHER).getRecordTypeId(); 
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
            System.debug(e.getMessage());
        }
        return res;
    }
    class InitData{
    @AuraEnabled
    public static InitData initForDepartmentCreate(String recordId,String type){
        InitData res = new InitData();
        try {
            Account acc = [
            select
            Hospital_Department_Class__c
            from Account where Id =: recordId
            ];
            res.hospitalDepartmentClass = acc.Hospital_Department_Class__c;
            if(type == 'BF'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_BF).getRecordTypeId();
            }else if(type == 'ENT'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_ENT).getRecordTypeId();
            }else if(type == 'GI'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_GI).getRecordTypeId();
            }else if(type == 'GS'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_GS).getRecordTypeId();
            }else if(type == 'GYN'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_GYN).getRecordTypeId();
            }else if(type == 'OTH'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_OTH).getRecordTypeId();
            }else if(type == 'URO'){
                res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_URO).getRecordTypeId();
            }
         } catch (Exception e) {
            System.debug(e.getMessage());
         }
         return res;
    }
    @AuraEnabled
    public static InitData initForRepairContact(String recordId){
        InitData res = new InitData();
        try{
            res.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_CON).getRecordTypeId();
        }catch(Exception e){
            System.debug(e.getMessage());
        }
        return res;
    }
    public class InitData{
        @AuraEnabled
        public String hospitalSalesdepartmentHP;
        @AuraEnabled
@@ -38,5 +97,9 @@
        public String hospitalOCMCategory;
        @AuraEnabled
        public String recordTypeId;
        @AuraEnabled
        public String hospitalDepartmentClass;
        @AuraEnabled
        public String name;
    }
}