package tech.glinfo.enbao.modules.sh.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import tech.glinfo.enbao.modules.sh.entity.ShDlinkEntity;

import java.util.List;
import java.util.Map;

/**
 * @author lyt
 * @date 2021/9/18 17:16
 */
@Mapper
public interface OtherShDlinkDao extends BaseMapper<ShDlinkEntity> {



    @Select("<script>" +
            "  SELECT * FROM sh_dlink a WHERE a.device_id = ${deviceId} AND #{time} between a.`start` and a.`end` AND a.status = 1 LIMIT 1"
            +
            " </script>")
    ShDlinkEntity checkTime(String time, Integer deviceId);

    @Select("<script>" +
            "   SELECT b.id, b.name, b.numbering, b.numbering_flag numberingFlag FROM sh_dlink_device a, sh_device b WHERE a.device_id = b.id AND a.dlink_id = ${id}"
            +
            " </script>")
    List<Map<String, Object>> dlinkDeviceList(Integer id);
}
