ApiErrorLogMapper.xml 3.25 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
<?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="cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper">
    <!--
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
     -->


    <select id="apiErrorLogList" resultType="cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO">
        select
        `id` ,
        `trace_id`,
        `user_id`,
        `user_type`,
        `application_name`,
        `request_method`,
        `request_url`,
        `request_params`,
        `user_ip`,
        `user_agent`,
        `exception_time`,
        `exception_name`,
        `exception_message`,
        `exception_root_cause_message`,
        `exception_stack_trace`,
        `exception_class_name`,
        `exception_file_name`,
        `exception_method_name`,
        `exception_line_number`,
        `process_status` ,
        `process_time`,
        `process_user_id`,
        `creator`,
        `create_time`,
        `updater`,
        `update_time`,
        `deleted`
        from infra_api_error_log
        where deleted = 0
        <if test="req.userId != null ">
            AND user_id = #{req.userId}
        </if>
        <if test="req.userType != null ">
            AND user_type = #{req.userType}
        </if>
        <if test="req.applicationName != null and req.applicationName != ''">
            AND application_name = #{req.applicationName}
        </if>
        <if test="req.requestUrl != null and req.requestUrl != ''">
            AND request_url like concat("%",concat(#{req.requestUrl},"%"))
        </if>
        <if test="req.beginExceptionTime != null and req.endExceptionTime != null">
            AND exception_time BETWEEN #{req.beginExceptionTime} and #{req.endExceptionTime}
        </if>
        <if test="req.processStatus != null ">
            AND process_status = #{req.processStatus}
        </if>
        order by id desc
        limit #{start}, #{size}
    </select>

    <select id="apiErrorLogCount" resultType="long">
        select count(1)
        from infra_api_error_log
        where deleted = 0
        <if test="req.userId != null ">
            AND user_id = #{req.userId}
        </if>
        <if test="req.userType != null ">
            AND user_type = #{req.userType}
        </if>
        <if test="req.applicationName != null and req.applicationName != ''">
            AND application_name = #{req.applicationName}
        </if>
        <if test="req.requestUrl != null and req.requestUrl != ''">
            AND request_url like concat("%",concat(#{req.requestUrl},"%"))
        </if>
        <if test="req.beginExceptionTime != null and req.endExceptionTime != null">
            AND exception_time BETWEEN #{req.beginExceptionTime} and #{req.endExceptionTime}
        </if>
        <if test="req.processStatus != null ">
            AND process_status = #{req.processStatus}
        </if>
    </select>
</mapper>