package com.ssj.dao.log.dao;


import com.ssj.framework.log.domain.RequestApiLog;
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;


/**
 * 
 * 类名称：RequestApiLogDao<br>
 * 类描述：请求api日志数据访问接口<br>
 * @version v1.0
 *
 */
@Repository
public interface RequestApiLogDao extends JpaRepository<RequestApiLog, String> {

    public Page<RequestApiLog> findAll(Pageable pageable);

    @Query(nativeQuery = true, value = "select count(*) from request_api_log")
    public long countByAll();

    @Query(nativeQuery = true, value = "delete from request_api_log where DATE_SUB(CURDATE(), INTERVAL ?1 DAY) >= date(request_date)")
    @Modifying
    public int deleteLogs(int days);
}
