package com.zsc.edu.gateway.modules.iot.device.repo;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsc.edu.gateway.modules.iot.device.entity.Device;
import com.zsc.edu.gateway.modules.iot.device.vo.DeviceVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


/**
 * @author zhuang
 */
public interface DeviceRepository extends BaseMapper<Device> {
    @Select("select * from iot_device where name=#{name}")
    Device findByName(@Param("name") String name);

    DeviceVo findById(@Param("id") Long id);

    @Select("select * from iot_device where client_id=#{clientId} and state=#{status} and online=#{online}")
    Device findByClientIdAndStateAndOnline(@Param("clientId") String clientId,
                                           @Param("status") Device.Status status,
                                           @Param("online") Boolean online);
}
