Class CampaignController
java.lang.Object
com.minicrm.mini_crm_api.controllers.CampaignController
REST controller for managing campaigns, including audience preview and
campaign creation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCampaign(@Valid CampaignDTO campaignDTO, org.springframework.security.oauth2.core.user.OAuth2User principal) Creates and launches a new campaign.org.springframework.data.domain.Page<Campaign>getAllCampaigns(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of all saved campaigns.Fetches the latest delivery statistics for a specific campaign.longpreviewAudience(@Valid RuleGroup audienceRules) Calculates the audience size for a given set of rules.
-
Constructor Details
-
CampaignController
public CampaignController()
-
-
Method Details
-
previewAudience
@PostMapping("/preview") @PreAuthorize("isAuthenticated()") public long previewAudience(@Valid @RequestBody @Valid RuleGroup audienceRules) Calculates the audience size for a given set of rules.- Parameters:
audienceRules- The nested rule structure to evaluate.- Returns:
- The total number of customers who match the rules.
-
createCampaign
@PostMapping @PreAuthorize("isAuthenticated()") @ResponseStatus(CREATED) public Campaign createCampaign(@Valid @RequestBody @Valid CampaignDTO campaignDTO, @AuthenticationPrincipal org.springframework.security.oauth2.core.user.OAuth2User principal) Creates and launches a new campaign.- Parameters:
campaignDTO- The DTO containing the details of the campaign to create.- Returns:
- The newly created and saved Campaign object.
-
getAllCampaigns
@GetMapping @PreAuthorize("isAuthenticated()") public org.springframework.data.domain.Page<Campaign> getAllCampaigns(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of all saved campaigns. Spring Boot automatically populates the Pageable object from URL parameters- Parameters:
pageable- An object containing the requested page, size, and sorting information.- Returns:
- A Page object containing the list of campaigns and pagination metadata.
-
getCampaignStats
@GetMapping("/{id}/stats") @PreAuthorize("isAuthenticated()") public CampaignStatsDTO getCampaignStats(@PathVariable String id) Fetches the latest delivery statistics for a specific campaign.- Parameters:
id- The unique ID of the campaign.- Returns:
- A DTO containing the delivery statistics.
-