package com.ssj.dao.sys.schoolmatecircle.dao;

import com.ssj.bean.sys.schoolmatecircle.domain.SchoolmateMessage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @author Mount Liu
 * @date 2018/8/15
 */
@Repository
public interface SchoolmateMessageDao extends JpaRepository<SchoolmateMessage, String> {

    /**
     * 根据用户删除当前时间点前的消息
     * @param userId
     * @param now
     */
    @Modifying
    void removeByUserIdAndCreateTimeBefore(String userId, Date now);

    /**
     * 根据用户id计算总数
     * @param userId
     * @return
     */
    long countByUserId(String userId);
}
