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

    <select id="getIsLotoStationPage" resultType="com.ktg.iscs.domain.vo.loto.IsLotoStationVO">
        SELECT
        l.*,
        w.workstation_name,
        m.name as map_name,
        m1.name as motor_map_name,
        m1.short_name as motor_map_short_name
        FROM
        is_loto_station 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
        LEFT JOIN is_map m1 ON m1.id = l.motor_map_id
        where
            l.del_flag = '0'
            <if test="isLotoStation.lotoName != null and isLotoStation.lotoName.trim != ''">
                and l.loto_name like concat('%',#{isLotoStation.lotoName},'%')
            </if>
            <if test="isLotoStation.lotoCode != null and isLotoStation.lotoCode.trim != ''">
                and l.loto_code like concat('%',#{isLotoStation.lotoCode},'%')
            </if>
            <if test="isLotoStation.workstationId != null">
                and l.workstation_id = #{isLotoStation.workstationId}
            </if>
            <if test="isLotoStation.lotoId != null">
                and l.loto_id = #{isLotoStation.lotoId}
            </if>
            ${isLotoStation.paramMap.workstationScope}
        ORDER BY
            l.order_num asc,
        l.loto_id DESC
    </select>
</mapper>
