SmartSceneDataMapper.xml 1.9 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.consumer.mapper.SmartSceneDataMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.consumer.entity.SmartSceneData">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="scene_id" jdbcType="BIGINT" property="sceneId" />
    <result column="type" jdbcType="TINYINT" property="type" />
    <result column="sort" jdbcType="TINYINT" property="sort" />
    <result column="param_key" jdbcType="VARCHAR" property="paramKey" />
    <result column="device_id" jdbcType="VARCHAR" property="deviceId" />
    <result column="param_value" jdbcType="VARCHAR" property="paramValue" />
    <result column="condition_rule" jdbcType="TINYINT" property="conditionRule" />
    <result column="execute_cycle" jdbcType="TINYINT" property="executeCycle" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, scene_id, `type`, sort, param_key, device_id, param_value
  </sql>
    <select id="findSceneDataByDeviceId" resultMap="BaseResultMap">
         select t1.scene_id,t2.condition_rule,t2.execute_cycle from smart_scene t2 left join smart_scene_data t1 on t1.scene_id=t2.id
        where device_id=#{deviceId} and param_key='scene_condition_status' and t2.status=1 and param_value like concat('%',#{order},'%') GROUP BY t1.scene_id
    </select>
  <select id="findBySceneId" resultMap="BaseResultMap">
        select t1.*,t2.condition_rule,t2.execute_cycle from smart_scene_data t1 left join smart_scene t2 on t1.scene_id=t2.id
    where scene_id=#{sceneId} and (param_key='scene_condition_status' or param_key='scene_condition_time') and t2.status=1
    <if test="order != null">
      and param_value like concat('%',#{order},'%')
    </if>
  </select>
</mapper>