package com.sikey.wa04.business.infrastructure.repository;

import com.sikey.wa04.business.domain.entity.MessageCenter;
import com.sikey.wa04.business.infrastructure.dto.model.MessageCenterModel;
import org.springframework.data.domain.Limit;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * MessageCenterRepository
 */
@Repository
public interface MessageCenterRepository extends JpaRepository<MessageCenterModel, Long> {
    void deleteByChildrenIdIn(List<String> childrenIds);

    List<MessageCenterModel> findByChildrenIdInOrderByCreatedAtDesc(List<String> childrenIds, Sort sort, Limit limit);

    int deleteByChildrenIdAndMessageType(
            @Param("childrenId") String childrenId,
            @Param("messageType") Integer messageType
    );
}
