<?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.yeejoin.amos.boot.module.hygf.api.mapper.HYGFMaintenanceTicketsMapper">


    <select id="qureyListByQueryparams"
            resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HYGFMaintenanceTicketsDto">
        select hygf_maintenance_tickets.* from
        hygf_maintenance_tickets
        left join
        hygf_maintenance on hygf_maintenance_tickets.maintenance_person_id = hygf_maintenance.sequence_nbr
        LEFT JOIN
        std_user_biz on hygf_maintenance.foundation_id = std_user_biz.sequence_nbr
        <where>
            std_user_biz.amos_user_id =#{amosUserId}
            and hygf_maintenance_tickets.is_delete = 0
            <if test="dto.handlerStatus != null and dto.handlerStatus !=''">
                And hygf_maintenance_tickets.handler_status = #{dto.handlerStatus}
            </if>
            <if test="dto.stationName != null and dto.stationName !=''">
                And hygf_maintenance_tickets.station_name LIKE CONCAT('%', #{dto.stationName}, '%')
            </if>
        </where>
        order by hygf_maintenance_tickets.sequence_nbr desc
    </select>


    <select id="queryForPageList" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HYGFMaintenanceTicketsDto">
        select hygf_maintenance_tickets.* from
        hygf_maintenance_tickets

        <where>
            hygf_maintenance_tickets.creator_user_id =#{amosUserId}
            <if test="dto.handlerStatus != null and dto.handlerStatus !=''">
                And hygf_maintenance_tickets.handler_status = #{dto.handlerStatus}
            </if>
            <if test="dto.stationName != null and dto.stationName !=''">
                And hygf_maintenance_tickets.station_name LIKE CONCAT('%', #{dto.stationName}, '%')
            </if>
        </where>
        order by hygf_maintenance_tickets.sequence_nbr desc
    </select>
</mapper>
