public with sharing class LexConsumApply_FromQISCtl {
    public LexConsumApply_FromQISCtl() {}
    @AuraEnabled
    public static List<Consum_Apply__c> rentalApp(String recordId){
        try {
            List<Consum_Apply__c> rep = [select Id from Consum_Apply__c where QIS_number__c =: recordId and Status__c <> '取消' and Status__c <> '删除'];
            return rep;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
    @AuraEnabled
    public static List<FieldDefinition> fieldDefineApp(){
        try {
            List<FieldDefinition> rep = [Select QualifiedApiName, EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Consum_Apply__c'];
            return rep;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
    //获取当前登录人的 id
    @AuraEnabled
    public static UserResult UserInfo_Owner() {
        UserResult result = new UserResult();
        ID myUserID = UserInfo.getUserId();
        try { 
            User tempUser =
                [select Id,isFormal_Stuff__c,FirstName,LastName from user where id = : myUserID ];
            result.id = tempUser.Id;
            result.isFormalStuff = tempUser.isFormal_Stuff__c;
            result.firstName = tempUser.FirstName == null ? '' : tempUser.FirstName;
            result.lastName = tempUser.LastName == null ? '' : tempUser.LastName;
        } catch (exception e) {
            result.result = e.getMessage();
        }
        return result;
    }
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new initData();
        try {
            QIS_Report__c rep = [select Id,next_action__c,QIS_Status__c,Hospital__c,Department_Class__c,Hospital_Department__c,Name from QIS_Report__c where Id =: recordId];
            res.qisReportId = rep.Id;
            res.nextAction = rep.next_action__c;
            res.qISStatus = rep.QIS_Status__c;
            res.hospital = rep.Hospital__c;
            res.departmentClass = rep.Department_Class__c;
            res.hospitalDepartment = rep.Hospital_Department__c;
            res.name = rep.Name;
            return res;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
    public class InitData{
        @AuraEnabled
        public String qisReportId;
        @AuraEnabled
        public String nextAction;
        @AuraEnabled
        public String qISStatus;
        @AuraEnabled
        public String hospital;
        @AuraEnabled
        public String departmentClass;
        @AuraEnabled
        public String hospitalDepartment;
        @AuraEnabled
        public String name;
    }
    public class UserResult {
        @AuraEnabled
        public string result;
        public UserResult( ) {
            result = 'Success';
        }
        @AuraEnabled
        public string id;
        @AuraEnabled
        public Boolean isFormalStuff;
        @AuraEnabled
        public string firstName;
        @AuraEnabled
        public string lastName;
    }
}