package com.reyun.repository;

import com.reyun.model.DemoAppointment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.math.BigInteger;


/**
 * Created by nolan on 06/06/2017.
 * description:
 */
public interface DemoAppointmentRepository extends JpaRepository<DemoAppointment, Long> {

    @Query(value = "select count(*) from demo_appointment where phone = ?1 and create_time between date_sub(date_add(now(), INTERVAL 8 hour), INTERVAL 30 day)  and date_add(now(), INTERVAL 8 hour)", nativeQuery = true)
    BigInteger countByPhone(String phone);
}
