<?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="me.zhengjie.modules.system.mapper.BusCommandMapper">
    <resultMap id="BaseResultMap" type="me.zhengjie.modules.system.domain.BusDeviceCommand">
        <id column="id" property="id"/>
        <result column="device_id" property="deviceId"/>
        <result column="command_name" property="commandName"/>
        <result column="command_type" property="commandType"/>
        <result column="description" property="description"/>
        <result column="status" property="status"/>
        <result column="command_params" property="commandParams"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="getCommandByDeviceId" resultType="me.zhengjie.modules.system.domain.dto.BusTreeVo">
        select CONCAT('c', id) id, CONCAT('d', device_id) pid, command_name name, description remark from bus_device_command where device_id = #{pid} order by id desc
    </select>
    
    <sql id="Base_Column_List">
        id, device_id, command_name, command_type, description, status, command_params, create_by, update_by, create_time, update_time
    </sql>

    <select id="findAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bus_device_command
        <where>
        </where>
        order by id desc
    </select>
</mapper>