<?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.hdkj.lt.core.log.dao.FhzgLogInfoMapper">


    <select id="selectLogInfoPage" resultType="com.hdkj.lt.core.log.model.dto.LogInfoDTO">
        select id, error_time, event_type, event_id, stage, related_id, related_category, source_system,
               source_system_error_id, operation_step, error_level, error_category, details,
               additional_info from fhzg_log_info
        <where>
            <if test="params.errorTimeStart != null and params.errorTimeStart != ''">
                and error_time <![CDATA[>=]]> #{params.errorTimeStart}
            </if>
            <if test="params.errorTimeEnd != null and params.errorTimeEnd != ''">
                and error_time <![CDATA[<=]]> #{params.errorTimeEnd}
            </if>
            <if test="params.eventType != null and params.eventType != ''">
                and event_type = #{params.eventType}
            </if>
            <if test="params.eventId != null and params.eventId != ''">
                and event_id LIKE CONCAT('%',#{params.eventId},'%')
            </if>
            <if test="params.relatedCategory != null and params.relatedCategory != ''">
                and related_category LIKE CONCAT('%', #{params.relatedCategory},'%')
            </if>
            <if test="params.relatedId != null and params.relatedId != ''">
                and related_id LIKE CONCAT('%',#{params.relatedId},'%')
            </if>
            <if test="params.sourceSystem != null and params.sourceSystem.size() > 0">
                and source_system in
                <foreach collection='params.sourceSystem' item='item' open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test="params.stage != null and params.stage != ''">
                and stage =#{params.stage}
            </if>
            <if test="params.errorLevel != null and params.errorLevel != ''">
                and error_level = #{params.errorLevel}
            </if>
            <if test="params.errorCategory != null and params.errorCategory != ''">
                and error_category = #{params.errorCategory}
            </if>
        </where>
        order by error_time desc
    </select>
</mapper>
