<?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.DeviceAttributeSpecsMapper">


    <resultMap type="DeviceAttributeSpecsEntity" id="DeviceAttributeSpecsResult">
        <result property="id" column="id"/>
        <result property="specsName" column="specs_name"/>
        <result property="specsValue" column="specs_value"/>
        <result property="attributeId" column="attribute_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="deviceAttributeSpecsColumns">
         a.id as "id" ,
         a.specs_name as "specsName" ,
         a.specs_value as "specsValue" ,
         a.attribute_id as "attributeId" ,
         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="findDeviceAttributeSpecsById" resultType="com.zcxk.entity.DeviceAttributeSpecsEntity">
        SELECT
        <include refid="deviceAttributeSpecsColumns"/>
        FROM sms_device_attribute_specs a
        WHERE a.id = #{id}
    </select>

    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.entity.DeviceAttributeSpecsEntity">
        SELECT
        <include refid="deviceAttributeSpecsColumns"/>
        FROM sms_device_attribute_specs a
        <where>
            <if test="attributeId != null  and attributeId != ''">
                and a.attribute_id =#{attributeId}
            </if>
            <if test="specsName != null  and specsName != ''">
                and a.specs_name LIKE concat('%',#{specsName},'%')
            </if>
        </where>
    </select>

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

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