package com.ywt.outpatient.domain.entity.center;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface AccountDetailRepository extends JpaRepository<AccountDetail, Integer> {

    /**
     * 在一定时间内得到某个人的所有流水详情
     * @param userId
     * @param startTime
     * @return
     */
    @Query(value = "select * from account_detail where user_id = ? and create_time >= ? and deleted = 0 ", nativeQuery = true)
    List<AccountDetail> getLastMonthTransactionRecord(int userId, String startTime);

    /**
     * 获取某一个时间段后的交易记录
     * @param userId 用户id
     * @param startTime 起始时间
     * @return
     */
    @Query(value = "SELECT * FROM account_detail WHERE user_id = ? AND create_time >= ? and deleted = 0 ", nativeQuery = true)
    List<AccountDetail> getTransactionRecordAfterDate(int userId, String startTime);

    /**
     * 获取某一个时间段内的交易记录
     * @param userId 用户id
     * @param startTime 起始时间
     * @return
     */
    @Query(value = "SELECT * FROM account_detail WHERE user_id = ? AND create_time >= ? AND create_time < ? AND deleted = 0", nativeQuery = true)
    List<AccountDetail> getTransactionRecordByTimePeriod(int userId, String startTime, String endTime);



}
