Class CampaignService
java.lang.Object
com.minicrm.mini_crm_api.services.CampaignService
Service layer containing the core business logic for creating and managing
campaigns.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCampaign(CampaignDTO campaignDTO, org.springframework.security.oauth2.core.user.OAuth2User principal) Creates a new campaign and publishes an event to process it asynchronously.org.springframework.data.domain.Page<Campaign>findAllCampaigns(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of all campaigns.findAudienceForCampaign(Campaign campaign) Finds the customer audience for a given campaign.longgetAudienceSize(RuleGroup ruleGroup) Calculates the size of the audience matching the given nested rules.
-
Constructor Details
-
CampaignService
public CampaignService()
-
-
Method Details
-
getAudienceSize
Calculates the size of the audience matching the given nested rules.- Parameters:
ruleGroup- The root RuleGroup containing nested rules and groups.- Returns:
- The count of customers matching the rules.
-
createCampaign
@Transactional public Campaign createCampaign(CampaignDTO campaignDTO, org.springframework.security.oauth2.core.user.OAuth2User principal) Creates a new campaign and publishes an event to process it asynchronously. This method is now non-blocking and returns immediately.- Parameters:
campaignDTO- The DTO containing the campaign details.- Returns:
- The newly created Campaign object.
-
findAudienceForCampaign
Finds the customer audience for a given campaign. This method is now public so it can be used by the CampaignEventListener.- Parameters:
campaign- The campaign for which to find the audience.- Returns:
- A list of customers who match the campaign's rules.
-
findAllCampaigns
public org.springframework.data.domain.Page<Campaign> findAllCampaigns(org.springframework.data.domain.Pageable pageable) Retrieves a paginated list of all campaigns. The sorting (e.g., by creation date) is defined in the Pageable object provided by the controller.- Parameters:
pageable- An object containing pagination and sorting information.- Returns:
- A Page of Campaign objects.
-