| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package nju.seec.helper.dao;
- import nju.seec.helper.entity.Message;
- import org.springframework.data.domain.Page;
- import org.springframework.data.domain.Pageable;
- import org.springframework.data.jpa.repository.JpaRepository;
- import org.springframework.data.jpa.repository.Modifying;
- import org.springframework.data.jpa.repository.Query;
- import org.springframework.stereotype.Repository;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.Set;
- /**
- * @author cst
- */
- @Repository
- public interface MessageDAO extends JpaRepository<Message, Long> {
- /**
- * 更新消息已读
- *
- * @param toUserId
- * @param messageIds
- */
- @Transactional(rollbackFor = Exception.class)
- @Modifying
- @Query("update Message m " +
- "set m.read=true " +
- "where m.toUserId=?1 " +
- "and m.id in ?2 ")
- void updateRead(Long toUserId, Set<Long> messageIds);
- /**
- * 删除消息
- *
- * @param toUserId
- * @param messageIds
- */
- void deleteByToUserIdAndIdIn(Long toUserId, Set<Long> messageIds);
- /**
- * 获取消息
- *
- * @param toUserId
- * @param read
- * @param key
- * @param pageable
- * @return
- */
- Page<Message> findByToUserIdAndReadAndContentContains(Long toUserId, Boolean read, String key, Pageable pageable);
- // /**
- // * 基于关联数据删除
- // *
- // * @param refId
- // * @param messageType
- // */
- // void deleteByRefIdAndType(Long refId, MessageType messageType);
- }
|