public with sharing class MassFileDownloaderController { @AuraEnabled public static ContentDocumentItem[] getFiles(Integer offset) { List linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =: System.Label.ReceivingNoteFolder]; List idList = new List(); for(ContentDocumentLink link: linkList){ idList.add(link.ContentDocumentId); } List conList = [ SELECT Id, Title, FileExtension, LatestPublishedVersionId,Owner.Name,OwnerId,LastModifiedDate FROM ContentDocument where Id in :idList order by LastModifiedDate desc limit 50 offset:offset ]; List itemList = new List(); for(ContentDocument con: conList){ itemList.add(new ContentDocumentItem(con,false)); } return itemList; } @AuraEnabled public static ContentDocumentItem[] searchFiles(String title,Integer offset){ if(title == ''){ List linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =: System.Label.ReceivingNoteFolder]; List idList = new List(); for(ContentDocumentLink link: linkList){ idList.add(link.ContentDocumentId); } List conList = [ SELECT Id, Title, FileExtension, LatestPublishedVersionId,Owner.Name,OwnerId,LastModifiedDate FROM ContentDocument where Id in :idList order by LastModifiedDate desc limit 50 offset:offset ]; List itemList = new List(); for(ContentDocument con: conList){ itemList.add(new ContentDocumentItem(con,false)); } return itemList; }else{ title = '%' + title + '%'; List linkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =: System.Label.ReceivingNoteFolder]; List idList = new List(); for(ContentDocumentLink link: linkList){ idList.add(link.ContentDocumentId); } List conList = [ SELECT Id, Title, FileExtension, LatestPublishedVersionId,Owner.Name,OwnerId,LastModifiedDate FROM ContentDocument where Id in :idList and Title like: title order by LastModifiedDate desc limit 50 offset:offset ]; List itemList = new List(); for(ContentDocument con: conList){ itemList.add(new ContentDocumentItem(con,false)); } return itemList; } } public class ContentDocumentItem { @AuraEnabled public ContentDocument con; @AuraEnabled public boolean isSelect; public ContentDocumentItem(ContentDocument con,Boolean isSelect){ this.con = con; this.isSelect = isSelect; } } }