package com.yihu.jw.base.dao.device;

import com.yihu.jw.entity.care.device.DeviceDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * @author yeshijie on 2018/1/10.
 */
public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {

    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);

    List<DeviceDetail> findByDeviceCode(String deviceCode);

    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);

    @Query("select a from DeviceDetail a where a.sim = ?1")
    List<DeviceDetail> findBySim(String sim);

    @Query("select a from DeviceDetail a where a.iccid = ?1")
    List<DeviceDetail> findByIccid(String iccid);

    @Query("select a from DeviceDetail a where a.imsi = ?1")
    List<DeviceDetail> findByImsi(String sim);

}
