Class CampaignService

java.lang.Object
com.minicrm.mini_crm_api.services.CampaignService

@Service public class CampaignService extends Object
Service layer containing the core business logic for creating and managing campaigns.
  • Constructor Details

    • CampaignService

      public CampaignService()
  • Method Details

    • getAudienceSize

      public long getAudienceSize(RuleGroup ruleGroup)
      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

      public List<Customer> findAudienceForCampaign(Campaign campaign)
      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.