Class CommunicationLogService

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

@Service public class CommunicationLogService extends Object
Service for managing the lifecycle of CommunicationLog entries.
  • Constructor Details

    • CommunicationLogService

      public CommunicationLogService()
  • Method Details

    • createLog

      public CommunicationLog createLog(String campaignId, String customerId)
      Creates a new communication log entry with a 'PENDING' status.
      Parameters:
      campaignId - The ID of the campaign this log belongs to.
      customerId - The ID of the customer this message is for.
      Returns:
      The newly created and saved CommunicationLog object.
    • updateLogStatus

      public void updateLogStatus(String logId, String status)
      Updates the status of an existing communication log.
      Parameters:
      logId - The ID of the log entry to update.
      status - The new status (e.g., "SENT" or "FAILED").
      Throws:
      IllegalArgumentException - if no log is found for the given ID.
    • getCampaignStats

      public CampaignStatsDTO getCampaignStats(String campaignId)
      Calculates the delivery statistics for a given campaign.
      Parameters:
      campaignId - The ID of the campaign.
      Returns:
      A DTO containing the counts of sent, failed, and pending messages.
    • updateLogStatusInBatch

      public void updateLogStatusInBatch(List<DeliveryReceiptDTO> receipts)
      Update status of multiple communication logs in a single efficient batch operation.
      Parameters:
      receipts - A list of DeliveryReceiptDTOs to process.