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

    <!--  实体栏位  -->
    <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.charge.core.entity.DeviceAttributeEntity">
        SELECT
        <include refid="deviceAttributeColumns"/>
        FROM sms_device_attribute a

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

    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.charge.core.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.charge.core.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>