package com.dtok.repository;

import com.dtok.entity.Devices;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

/**
 * @Description
 * @Author C.J
 * @Date 2024-03-10
 */

public interface DevicesRepository extends JpaRepository<Devices, String>, JpaSpecificationExecutor<Devices> {


    @Query(value = "select d from Devices d left join Account a on d.account = a.id where a.username = :username")
    List<Devices> searchAllByAccountUsername(@Param("username") String username);

    Devices findFirstByAccountAndAndroidId(Long user,String androidId);

    Devices findFirstByUuid(String uuid);

    Integer countByAndroidId(String androidId);
    void deleteDevicesByUuid(String uuid);
}
