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

    <select id="getIsLotoSwitchMapPage" resultType="com.ktg.iscs.domain.vo.loto.IsLotoSwitchMapVO">
        SELECT
        l.*,
        w.workstation_name,
        m.name as map_name
        FROM
        is_loto_switch_map l
        LEFT JOIN is_workstation w ON w.workstation_id = l.workstation_id
        LEFT JOIN sys_user u ON u.user_id = l.create_by
        LEFT JOIN is_map m ON m.id = l.map_id
        where
        l.del_flag = '0'
        <if test="isLotoSwitchMap.switchMapName != null and isLotoSwitchMap.switchMapName.trim != ''">
            and l.switch_map_name like concat('%',#{isLotoSwitchMap.switchMapName},'%')
        </if>
        <if test="isLotoSwitchMap.switchMapCode != null and isLotoSwitchMap.switchMapCode.trim != ''">
            and l.switch_map_code like concat('%',#{isLotoSwitchMap.switchMapCode},'%')
        </if>
        <if test="isLotoSwitchMap.workstationId != null">
            and l.workstation_id = #{isLotoSwitchMap.workstationId}
        </if>
        <if test="isLotoSwitchMap.switchMapId != null">
            and l.switch_map_id = #{isLotoSwitchMap.switchMapId}
        </if>
        ORDER BY
        l.order_num asc,
        l.switch_map_id DESC
    </select>
</mapper>
