<?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.qmth.sop.business.mapper.SysDeviceMapper">

    <select id="query" resultType="com.qmth.sop.business.bean.result.SysDeviceResult">
        select a.*,s.name supplier  from sys_device a
        left join sys_supplier s on s.id=a.supplier_id
        <where>
            <if test="supplierId != null and supplierId != ''">
                and a.supplier_id = #{supplierId}
            </if>
            <if test="brand != null and brand != ''">
                and a.brand = #{brand}
            </if>
            <if test="model != null and model != ''">
                and a.model = #{model}
            </if>
            <if test="deviceCode != null and deviceCode != ''">
                and a.device_code LIKE CONCAT('%',#{deviceCode},'%')
            </if>
            <if test="serialNo != null and serialNo != ''">
                and a.serial_no LIKE CONCAT('%',#{serialNo},'%')
            </if>
            <if test="status != null and status != ''">
                and a.status = #{status}
            </if>
            <if test="bound != null and bound != ''">
                and a.bound = #{bound}
            </if>


            <if test="enable != null">
                <choose>
                    <when test="enable">
                        and a.enable =1
                    </when>
                    <otherwise>
                        and a.enable = 0
                    </otherwise>
                </choose>
            </if>
        </where>
        order by a.create_time desc
    </select>
</mapper>