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


    <!--  实体栏位  -->
    <sql id="deviceSetupMethodColumns">
         a.id as "id" ,
         a.device_id as "deviceId" ,
         a.attribute_id as "attributeId" ,
         a.type as "type" ,
         a.method as "method" ,
         a.params as "params" ,
         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="findDeviceSetupMethodById" resultType="com.zcxk.charge.core.entity.DeviceSetupMethodEntity">
        SELECT
        <include refid="deviceSetupMethodColumns"/>
        FROM sms_device_setup_method a
        WHERE a.id = #{id} and a.status=1
    </select>

    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.charge.core.entity.DeviceSetupMethodEntity">
        SELECT
        <include refid="deviceSetupMethodColumns"/>
        FROM sms_device_setup_method a
        <where>
            <if test="deviceId != null ">and a.device_id = #{deviceId}</if>
            <if test="attributeId != null ">and a.attribute_id = #{attributeId}</if>
            <if test="type != null ">and a.type = #{type}</if>
            <if test="method != null  and method != ''">and a.method = #{method}</if>
            and a.status=1
        </where>
    </select>
</mapper>