package com.smyhub.store.mengyastorebackendjava.repository;

import com.smyhub.store.mengyastorebackendjava.entity.ChatMessage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface ChatMessageRepository extends JpaRepository<ChatMessage, String> {

    List<ChatMessage> findByAccountIdOrderBySentAtAsc(String accountId);

    List<ChatMessage> findAllByOrderByAccountIdAscSentAtAsc();

    @Transactional
    void deleteByAccountId(String accountId);
}
