<?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.zcxk.dao.DeviceAttributeMapper">


    <resultMap type="DeviceAttributeEntity" id="DeviceAttributeResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="identifier" column="identifier"/>
        <result property="dataType" column="data_type"/>
        <result property="description" column="description"/>
        <result property="unit" column="unit"/>
        <result property="deviceModeId" column="device_mode_id"/>
        <result property="status" column="status"/>
        <result property="dateCreate" column="date_create"/>
        <result property="createBy" column="create_by"/>
        <result property="dateUpdate" column="date_update"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <!--  实体栏位  -->
    <sql id="deviceAttributeColumns">
         a.id as "id" ,
         a.name as "name" ,
         a.identifier as "identifier" ,
         a.data_type as "dataType" ,
         a.description as "description" ,
         a.unit as "unit" ,
         a.device_mode_id as "deviceModeId" ,
         a.status as "status" ,
         a.date_create as "dateCreate" ,
         a.create_by as "createBy" ,
         a.date_update as "dateUpdate" ,
         a.update_by as "updateBy" 
     </sql>


    <!--  根据主键获取实体   -->
    <select id="findDeviceAttributeById" resultType="com.zcxk.entity.DeviceAttributeEntity">
        SELECT
        <include refid="deviceAttributeColumns"/>
        FROM sms_device_attribute a

        WHERE a.id = #{id}
    </select>

    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.entity.DeviceAttributeEntity">
        SELECT
        <include refid="deviceAttributeColumns"/>
        FROM sms_device_attribute a

        <where>

            <if test="name != null  and name != ''">
                and a.name LIKE concat('%',#{name},'%')
            </if>
        </where>
    </select>

    <!--  根据获取实体 page   -->
    <select id="findPage" resultType="com.zcxk.entity.DeviceAttributeEntity">
        SELECT
        <include refid="deviceAttributeColumns"/>
        FROM sms_device_attribute a

        <where>
            <if test="deviceAttribute.name != null  and deviceAttribute.name != ''">
                and a.name LIKE concat('%',#{deviceAttribute.name},'%')
            </if>
        </where>
    </select>
</mapper>