<?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="com.fuyuanshen.equipment.mapper.DeviceTypeMapper">
    <resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.DeviceType">
        <id column="id" property="id"/>
        <result column="type_name" property="typeName"/>
        <result column="is_support_ble" property="isSupportBle"/>
        <result column="locate_mode" property="locateMode"/>
        <result column="network_way" property="networkWay"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="communication_mode" property="communicationMode"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        , type_name, is_support_ble, locate_mode, network_way, create_by, update_by, create_time, update_time,communication_mode
    </sql>


    <!-- 查询所有设备类型 -->
    <select id="findAll" resultMap="BaseResultMap">
        SELECT DISTINCT dt.*
        FROM device_type dt
        <where>
            <if test="criteria.typeName != null and criteria.typeName.trim() != ''">
                and dt.type_name like concat('%', TRIM(#{criteria.typeName}), '%')
            </if>
            <if test="criteria.deviceTypeId != null">
                and dt.id = #{criteria.deviceTypeId}
            </if>
            <if test="criteria.customerId != null">
                and dt.owner_customer_id = #{criteria.customerId}
            </if>
        </where>
        ORDER BY dt.create_time DESC
    </select>
</mapper>