Added pagination for listing SMS campaign
This commit is contained in:
+7
-3
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.campaigns.sms.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
@@ -50,6 +49,8 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
import org.apache.fineract.infrastructure.core.service.SearchParameters;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -125,9 +126,12 @@ public class SmsCampaignApiResource {
|
||||
|
||||
@GET
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllCampaigns(@Context final UriInfo uriInfo) {
|
||||
public String retrieveAllCampaigns(@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit,
|
||||
@QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
this.platformSecurityContext.authenticatedUser().validateHasReadPermission(SmsCampaignConstants.RESOURCE_NAME);
|
||||
Collection<SmsCampaignData> smsCampaignDataCollection = this.smsCampaignReadPlatformService.retrieveAll();
|
||||
final SearchParameters searchParameters = SearchParameters.forSMSCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Page<SmsCampaignData> smsCampaignDataCollection = this.smsCampaignReadPlatformService.retrieveAll(searchParameters);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, smsCampaignDataCollection);
|
||||
}
|
||||
|
||||
+3
-2
@@ -19,15 +19,16 @@
|
||||
package org.apache.fineract.infrastructure.campaigns.sms.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.fineract.infrastructure.campaigns.sms.data.SmsCampaignData;
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
import org.apache.fineract.infrastructure.core.service.SearchParameters;
|
||||
|
||||
public interface SmsCampaignReadPlatformService {
|
||||
|
||||
public SmsCampaignData retrieveOne(final Long campaignId);
|
||||
|
||||
public List<SmsCampaignData> retrieveAll();
|
||||
public Page<SmsCampaignData> retrieveAll(final SearchParameters searchParameters);
|
||||
|
||||
public SmsCampaignData retrieveTemplate(final String reportType);
|
||||
|
||||
|
||||
+17
-3
@@ -37,7 +37,10 @@ import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaignStatus
|
||||
import org.apache.fineract.infrastructure.campaigns.sms.exception.SmsCampaignNotFound;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
import org.apache.fineract.infrastructure.core.service.PaginationHelper;
|
||||
import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
|
||||
import org.apache.fineract.infrastructure.core.service.SearchParameters;
|
||||
import org.apache.fineract.portfolio.calendar.service.CalendarDropdownReadPlatformService;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
@@ -57,6 +60,7 @@ public class SmsCampaignReadPlatformServiceImpl implements SmsCampaignReadPlatfo
|
||||
private final SmsCampaignDropdownReadPlatformService smsCampaignDropdownReadPlatformService;
|
||||
private final SmsCampaignMapper smsCampaignMapper;
|
||||
private final CalendarDropdownReadPlatformService calendarDropdownReadPlatformService;
|
||||
private final PaginationHelper<SmsCampaignData> paginationHelper = new PaginationHelper<>();
|
||||
|
||||
@Autowired
|
||||
public SmsCampaignReadPlatformServiceImpl(final RoutingDataSource dataSource,
|
||||
@@ -81,10 +85,20 @@ public class SmsCampaignReadPlatformServiceImpl implements SmsCampaignReadPlatfo
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsCampaignData> retrieveAll() {
|
||||
public Page<SmsCampaignData> retrieveAll(final SearchParameters searchParameters) {
|
||||
final Integer visible = 1;
|
||||
final String sql = "select " + this.smsCampaignMapper.schema() + " where sc.is_visible = ?";
|
||||
return this.jdbcTemplate.query(sql, this.smsCampaignMapper, new Object[] {visible});
|
||||
final StringBuilder sqlBuilder = new StringBuilder(200);
|
||||
sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
|
||||
sqlBuilder.append(this.smsCampaignMapper.schema() + " where sc.is_visible = ? ");
|
||||
if (searchParameters.isLimited()) {
|
||||
sqlBuilder.append(" limit ").append(searchParameters.getLimit());
|
||||
if (searchParameters.isOffset()) {
|
||||
sqlBuilder.append(" offset ").append(searchParameters.getOffset());
|
||||
}
|
||||
}
|
||||
final String sqlCountRows = "SELECT FOUND_ROWS()";
|
||||
return this.paginationHelper.fetchPage(jdbcTemplate, sqlCountRows, sqlBuilder.toString(), new Object[] { visible },
|
||||
this.smsCampaignMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -43,9 +43,9 @@ public enum JobName {
|
||||
UPDATE_SAVINGS_DORMANT_ACCOUNTS("Update Savings Dormant Accounts"), //
|
||||
ADD_PERIODIC_ACCRUAL_ENTRIES_FOR_LOANS_WITH_INCOME_POSTED_AS_TRANSACTIONS("Add Accrual Transactions For Loans With Income Posted As Transactions"),
|
||||
EXECUTE_REPORT_MAILING_JOBS("Execute Report Mailing Jobs"),
|
||||
UPDATE_SMS_OUTBOUND_WITH_CAMPAIGN_MESSAGE("Update Sms Outbound with campaign message"),
|
||||
SEND_MESSAGES_TO_SMS_GATEWAY("Send messages to SMS gateway"),
|
||||
GET_DELIVERY_REPORTS_FROM_SMS_GATEWAY("Get delivery reports from SMS gateway");
|
||||
UPDATE_SMS_OUTBOUND_WITH_CAMPAIGN_MESSAGE("Update SMS Outbound with Campaign Message"),
|
||||
SEND_MESSAGES_TO_SMS_GATEWAY("Send Messages to SMS Gateway"),
|
||||
GET_DELIVERY_REPORTS_FROM_SMS_GATEWAY("Get Delivery Reports from SMS Gateway");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ ALTER TABLE `sms_messages_outbound`
|
||||
|
||||
|
||||
INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `job_key`, `initializing_errorlog`, `is_active`, `currently_running`, `updates_allowed`, `scheduler_group`, `is_misfired`) VALUES
|
||||
('Update Sms Outbound with campaign message', 'Update Sms Outbound with campaign message', '0 0 0 1/1 * ? *', NOW(), 3, NULL, NULL, NULL, 'Update Sms Outbound with campaign message1 _ DEFAULT', NULL, 0, 0, 1, 1, 0),
|
||||
('Send messages to SMS gateway', 'Send messages to SMS gateway', '0 0 0 1/1 * ? *', NOW(), 3, NULL, NULL, NULL, 'Send messages to SMS gateway1 _ DEFAULT', NULL, 0, 0, 1, 1, 0),
|
||||
('Get delivery reports from SMS gateway', 'Get delivery reports from SMS gateway', '0 0 0 1/1 * ? *', NOW(), 3, NULL, NULL, NULL, 'Get delivery reports from SMS gateway1 _ DEFAULT', NULL, 0, 0, 1, 1, 0);
|
||||
('Update SMS Outbound with Campaign Message', 'Update SMS Outbound with Campaign Message', '0 0 5 1/1 * ? *', NOW(), 3, NULL, NULL, NULL, 'Update SMS Outbound with Campaign Message1 _ DEFAULT', NULL, 1, 0, 1, 4, 0),
|
||||
('Send Messages to SMS Gateway', 'Send Messages to SMS Gateway', '0 0 5 1/1 * ? *', NOW(), 2, NULL, NULL, NULL, 'Send Messages to SMS Gateway1 _ DEFAULT', NULL, 1, 0, 1, 4, 0),
|
||||
('Get Delivery Reports from SMS Gateway', 'Get Delivery Reports from SMS Gateway', '0 0 5 1/1 * ? *', NOW(), 1, NULL, NULL, NULL, 'Get Delivery Reports from SMS Gateway1 _ DEFAULT', NULL, 1, 0, 1, 4, 0);
|
||||
|
||||
INSERT INTO `m_permission`
|
||||
(`grouping` ,`code` ,`entity_name`, `action_name`, `can_maker_checker`) VALUES
|
||||
|
||||
Reference in New Issue
Block a user