<?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.ktg.iscs.mapper.IsLockCabinetMapper">

    <select id="getIsLockCabinetPage" resultType="com.ktg.iscs.domain.IsLockCabinet">
        SELECT
            c.*,
            h.serial_number,
            w.workstation_name
        FROM
            is_lock_cabinet c
                LEFT JOIN is_hardware h ON h.id = c.hardware_id
                LEFT JOIN is_workstation w ON w.workstation_id = c.workstation_id
        <where>
            <if test="isLockCabinet.cabinetName != null and isLockCabinet.cabinetName != ''">
                AND c.cabinet_name like concat('%', #{isLockCabinet.cabinetName}, '%')
            </if>
            <if test="isLockCabinet.isOnline != null and isLockCabinet.isOnline != ''">
                AND c.is_online = #{isLockCabinet.isOnline}
            </if>
            <if test="isLockCabinet.status != null and isLockCabinet.status != ''">
                AND c.status = #{isLockCabinet.status}
            </if>
        </where>
            ORDER BY c.cabinet_id DESC
    </select>
</mapper>
