Skip to content

Instantly share code, notes, and snippets.

@veeranjik
Last active October 13, 2019 14:47
Show Gist options
  • Save veeranjik/736e21895423dd0ec24530237900ddff to your computer and use it in GitHub Desktop.
Save veeranjik/736e21895423dd0ec24530237900ddff to your computer and use it in GitHub Desktop.
/** Class Name : OpportunityController
* Description : This class is used get the opportunities
* Created By : Veeranjaneyulu k
* Created On : 11/10/2019
*
* Modification Log:
* --------------------------------------------------------------------------------------------------------------------------------------
* Developer Date Modification ID Description
* --------------------------------------------------------------------------------------------------------------------------------------
*
**/
public with sharing class OpportunityController {
public class PagedResult {
@AuraEnabled
public Integer pageSize {get;set;}
@AuraEnabled
public Integer page {get;set;}
@AuraEnabled
public Integer pages {get;set;}
@AuraEnabled
public Integer total {get;set;}
@AuraEnabled
public List < Opportunity > funds {get;set;}
}
@AuraEnabled(cacheable = true)
public static PagedResult getFunds(Decimal pageSize, Decimal pageNumber, Integer myOffSet) {
Integer pSize = (Integer) pageSize;
PagedResult r = new PagedResult();
r.pageSize = pSize;
Integer offset = ((Integer) pageNumber - 1) * pSize;
r.page = (Integer) pageNumber;
String countSQL = 'SELECT count() FROM Opportunity';
r.total = Database.countQuery(countSQL);
r.pages = (Math.ceil(r.total / r.pageSize)).intValue();
if (r.pages == 0) {
r.pages = 1;
}
String sql = 'select id,name,account.name,amount,Type,ExpectedRevenue,CloseDate,Probability,stageName,Owner.alias from opportunity ORDER BY Name LIMIT 5 OFFSET 5';
r.funds = [select id, name, account.name, amount, Type, ExpectedRevenue, CloseDate, Probability, stageName, Owner.alias from opportunity ORDER BY Name LIMIT 5 OFFSET: myOffSet];
return r;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment