VideoPoolDao.java 1.35 KB
package cn.fw.freya.dao;


import cn.fw.freya.model.data.pool.VideoPool;
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.Date;
import java.util.List;

/**
 * 视频处理
 *
 * @author kurisu
 */
@Repository
public interface VideoPoolDao extends JpaRepository<VideoPool, Long> {
    /**
     * 删除
     *
     * @param accountNo    账户号
     * @param previousDay  前一天
     * @param type         账户类型
     * @param resourceType 资源类型
     */
    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query("delete from VideoPool where accountNo = ?1 and reportDate = ?2 and type=?3 and resourceType=?4")
    void deleteByAccountNoAndDate(String accountNo, Date previousDay, Integer type, Integer resourceType);

    /**
     * 获取今天上报的数据
     *
     * @param accountNo  账户号
     * @param type       账户类型
     * @param reportDate 上报日期
     * @return
     */
    @Query("select v from VideoPool v where v.accountNo = ?1 and v.type = ?2 and v.reportDate >= ?3")
    List<VideoPool> getHasReportDate(String accountNo, Integer type, Date reportDate);
}