package com.YuyeTech.TPlat.repository;

import com.YuyeTech.TPlat.dataobject.DeviceInfo;
import com.YuyeTech.TPlat.dto.DeviceBindDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

/**
 * @author:slambb
 * @date:2020/6/11
 */
public interface DeviceInfoRepository extends JpaRepository<DeviceInfo,String> {

    List<DeviceInfo> findAllByIdentifier(String identifier);

    /**
     * 根据uuid 查找字段
     * @param uuid
     * @return
     */
    Optional<DeviceInfo> findByDeviceUuid(String uuid);

    /**
     *
     * @param uuid
     * @param userId
     * @return
     */
    List<DeviceInfo> findByUserIdOrDeviceUuid(String userId,String uuid);

    Optional<DeviceInfo>  findByUserIdAndDeviceUuid(String userId,String uuid);

    Optional<DeviceInfo>  findByUserIdAndDeviceType(String userId,Integer type);

    Optional<DeviceInfo>  findByDeviceUuidAndDeviceType(String userId,Integer type);


    List<DeviceBindDTO> findAllByUserId(String userId);

    Page<DeviceInfo> findAllByDeviceUuid(String deviceUuid, Pageable pageable);
}
