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


    <!--  实体栏位  -->
    <sql id="deviceTypeColumns">
         a.id as "id" ,
         a.manufacturer_name as "manufacturerName" ,
         a.manufacturer_id as "manufacturerId" ,
         a.device_type as "deviceType" ,
         a.device_mode as "deviceMode" ,
         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="findDeviceTypeById" resultType="com.zcxk.charge.core.entity.DeviceTypeEntity">
        SELECT
        <include refid="deviceTypeColumns"/>
        FROM sms_device_type a
        WHERE a.id = #{id}
    </select>

    <!--  根据获取实体List   -->
    <select id="findListByName" resultType="com.zcxk.charge.core.entity.DeviceTypeEntity">
        SELECT
        <include refid="deviceTypeColumns"/>
        FROM sms_device_type a
        <where>
            <if test="manufacturerName != null  and manufacturerName != ''">
                and a.manufacturer_name = #{manufacturerName}
            </if>
            <if test="deviceType != null  and deviceType != ''">
                and a.device_type = #{deviceType}
            </if>
            <if test="deviceMode != null  and deviceMode != ''">
                and a.device_mode = #{deviceMode}
            </if>
        </where>
    </select>


    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.charge.core.entity.DeviceTypeEntity">
        SELECT
        <include refid="deviceTypeColumns"/>
        FROM sms_device_type a
        <where>
            <if test="manufacturerName != null  and manufacturerName != ''">
                and a.manufacturer_name LIKE concat('%',#{manufacturerName},'%')
            </if>
        </where>
    </select>

    <!--  根据获取实体 page   -->
    <select id="findPage" resultType="com.zcxk.charge.core.entity.DeviceTypeEntity">
        SELECT
        <include refid="deviceTypeColumns"/>
        FROM sms_device_type a
        <where>
            <if test="deviceType.manufacturerName != null  and deviceType.manufacturerName != ''">
                and a.manufacturer_name LIKE concat('%',#{deviceType.manufacturerName},'%')
            </if>
        </where>
    </select>
</mapper>